diff --git a/district/models.py b/district/models.py index b0e965dc5345fb30d15ccf9b70cfa7ab8d805274..c111fcf613aded6689892009c1ecf2affb898dbd 100644 --- a/district/models.py +++ b/district/models.py @@ -485,14 +485,6 @@ class DistrictPersonPage(SubpageMixin, MetadataPageMixin, Page): else self.root_page.fallback_image ) - @property - def pageperex(self): - """ - Vraci perex Pirata nejblizzsi lokalnimu kontextu. Zamerne jiny nazev, aby - v template bylo na vyber z x.perex, x.person.perex a x.pageperex - """ - return self.perex or self.person.perex - def get_context(self, request): context = super().get_context(request) # Na strance detailu cloveka se vpravo zobrazuji 3 dalsi nahodne profily @@ -503,6 +495,20 @@ class DistrictPersonPage(SubpageMixin, MetadataPageMixin, Page): context["random_people"] = context["random_people"][:3] return context + def get_email(self): + return self.person.email if self.person.email else self.email + + def get_phone(self): + return self.person.phone if self.person.phone else self.phone + + @property + def pageperex(self): + """ + Vraci perex Pirata nejblizzsi lokalnimu kontextu. Zamerne jiny nazev, aby + v template bylo na vyber z x.perex, x.person.perex a x.pageperex + """ + return self.perex or self.person.perex + class DistrictPeoplePage(SubpageMixin, MetadataPageMixin, Page): ### FIELDS diff --git a/district/templates/district/base.html b/district/templates/district/base.html index 879a8009059338b6c4e24885a9a817a6db1b17bf..dd96bd42e0eb7269ffcee5c17340e51a6629ad3d 100644 --- a/district/templates/district/base.html +++ b/district/templates/district/base.html @@ -276,13 +276,13 @@ <div class="container container--default"> <div class="grid gap-4 grid-cols-1 md:grid-cols-2 xl:grid-cols-3"> {% if page.root_page.footperson_coord %} - {% include "shared/person_badge_snippet.html" with person=page.root_page.footperson_coord title="Koordinátor" %} + {% include "shared/person_badge_snippet.html" with person_page=page.root_page.footperson_coord title="Koordinátor" %} {% endif %} {% if page.root_page.footperson_electman %} - {% include "shared/person_badge_snippet.html" with person=page.root_page.footperson_electman title="Volební manažer" %} + {% include "shared/person_badge_snippet.html" with person_page=page.root_page.footperson_electman title="Volební manažer" %} {% endif %} {% if page.root_page.footperson_media %} - {% include "shared/person_badge_snippet.html" with person=page.root_page.footperson_media title="Kontakt pro média" %} + {% include "shared/person_badge_snippet.html" with person_page=page.root_page.footperson_media title="Kontakt pro média" %} {% endif %} </div> </div> diff --git a/district/templates/district/blocks/people_group_block.html b/district/templates/district/blocks/people_group_block.html index 44907e43ac7c65ab48990e82cfd10d8e5350108d..af30db41a19bfcb342f05f99c967db7aff5b7a8d 100644 --- a/district/templates/district/blocks/people_group_block.html +++ b/district/templates/district/blocks/people_group_block.html @@ -2,7 +2,7 @@ {{ self.group_title }} </h2> <div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 row-gap-8 col-gap-8"> - {% for person in self.person_list %} + {% for person_page in self.person_list %} {% include "shared/person_badge_snippet.html" %} {% endfor %} </div> diff --git a/district/templates/district/district_article_page.html b/district/templates/district/district_article_page.html index d0b86bcd94d8a71dedc50b81110d04bd2cfadfed..6f1899b9e1bfb71d22e3cf4208da62de9fc99d65 100644 --- a/district/templates/district/district_article_page.html +++ b/district/templates/district/district_article_page.html @@ -38,7 +38,7 @@ {{ page.text|richtext }} {% if page.author_page %} - {% include "shared/person_badge_snippet.html" with person=page.author_page title="Autor" %} + {% include "shared/person_badge_snippet.html" with person_page=page.author_page title="Autor" %} {% endif %} </div> diff --git a/district/templates/district/district_contact_page.html b/district/templates/district/district_contact_page.html index ac85895681a9759ef0dd84657a8a31167602da26..730c806bc2c0059a702aec75fe4817d2947f77e6 100644 --- a/district/templates/district/district_contact_page.html +++ b/district/templates/district/district_contact_page.html @@ -16,7 +16,7 @@ <div> <h2 class="head-heavy-sm mb-2 lg:mb-4 mt-4">{{ item.value.name }}</h2> <div class="card elevation-3 p-3 mb-3"> - {% include "shared/person_badge_snippet.html" with person=item.value.person %} + {% include "shared/person_badge_snippet.html" with person_page=item.value.person %} </div> </div> diff --git a/district/templates/district/district_person_page.html b/district/templates/district/district_person_page.html index c2abb8506dbb165f189d2684b43f71dec096640b..c9ff2ed846a8c95107058a7925e472933cc83c57 100644 --- a/district/templates/district/district_person_page.html +++ b/district/templates/district/district_person_page.html @@ -91,7 +91,7 @@ <h2>Lidé</h2> <div class="space-y-4 mt-4"> {% for person in random_people %} - {% include "shared/person_badge_snippet.html" with person=person skipcontacts=1 %} + {% include "shared/person_badge_snippet.html" with person_page=person skipcontacts=1 %} {% endfor %} </div> <a href="{{ page.root_page.people_page.url }}" diff --git a/region/templates/region/base.html b/region/templates/region/base.html index d616216d8cae01e4dbd4c796da62c14afbb37454..92e286f23bc14f7fe20229c564bc45751c896b84 100644 --- a/region/templates/region/base.html +++ b/region/templates/region/base.html @@ -257,13 +257,13 @@ <div class="container container--default"> <div class="grid gap-4 grid-cols-1 md:grid-cols-2 xl:grid-cols-3"> {% if page.root_page.footperson_coord %} - {% include "shared/person_badge_snippet.html" with person=page.root_page.footperson_coord title="Koordinátor" %} + {% include "shared/person_badge_snippet.html" with person_page=page.root_page.footperson_coord title="Koordinátor" %} {% endif %} {% if page.root_page.footperson_electman %} - {% include "shared/person_badge_snippet.html" with person=page.root_page.footperson_electman title="Volební manažer" %} + {% include "shared/person_badge_snippet.html" with person_page=page.root_page.footperson_electman title="Volební manažer" %} {% endif %} {% if page.root_page.footperson_media %} - {% include "shared/person_badge_snippet.html" with person=page.root_page.footperson_media title="Kontakt pro média" %} + {% include "shared/person_badge_snippet.html" with person_page=page.root_page.footperson_media title="Kontakt pro média" %} {% endif %} </div> </div> diff --git a/region/templates/region/region_contact_page.html b/region/templates/region/region_contact_page.html index 66901d6669cab9644b4d79b2ff200ab0195f9cb4..52654af8acce4006888392f485b1d376ac302f4b 100644 --- a/region/templates/region/region_contact_page.html +++ b/region/templates/region/region_contact_page.html @@ -16,7 +16,7 @@ <div> <h2 class="head-heavy-sm mb-2 lg:mb-4 mt-4">{{ item.value.name }}</h2> <div class="card elevation-3 p-3 mb-3"> - {% include "shared/person_badge_snippet.html" with person=item.value.person %} + {% include "shared/person_badge_snippet.html" with person_page=item.value.person %} </div> </div> diff --git a/region/templates/region/region_people_page.html b/region/templates/region/region_people_page.html index 49cad809f29066ee6dca0f2334da1164b1a82a66..4e9aa4e6a6d800eb279091cc2c81b0a2e1d2182c 100644 --- a/region/templates/region/region_people_page.html +++ b/region/templates/region/region_people_page.html @@ -12,8 +12,8 @@ <h2 class="head-heavy-base mb-4">Členové a příznivci</h2> <div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 row-gap-8 col-gap-8"> - {% for person in people %} - {% include "shared/person_badge_snippet.html" with person=person %} + {% for person_page in people %} + {% include "shared/person_badge_snippet.html" %} {% endfor %} </div> diff --git a/region/templates/region/region_person_page.html b/region/templates/region/region_person_page.html index 13cde222adb5fa73fa078cdb62aefff99f8ba213..4107dbd8e416b3ac9b5b26b5cdd141d5e286a6a8 100644 --- a/region/templates/region/region_person_page.html +++ b/region/templates/region/region_person_page.html @@ -77,8 +77,8 @@ </div> <div class="space-y-4"> - {% for person in random_people %} - {% include "shared/person_badge_snippet.html" with person=person skipcontacts=1 %} + {% for person_page in random_people %} + {% include "shared/person_badge_snippet.html" with person_page=person skipcontacts=1 %} {% endfor %} </div> diff --git a/shared/templates/shared/person_badge_snippet.html b/shared/templates/shared/person_badge_snippet.html index b21facb8f53b32be331289610074e276bc69ebee..6f53bc19233306f663418fb63198fae205d32246 100644 --- a/shared/templates/shared/person_badge_snippet.html +++ b/shared/templates/shared/person_badge_snippet.html @@ -1,36 +1,38 @@ {% load wagtailimages_tags %} <div class="badge "> - <a href="{{ person.url }}" class="avatar badge__avatar avatar--sm"> - {% image person.profile_photo max-80x80 as profile_img %} - <img src="{% firstof person.person.portrait profile_img.url %}" alt="{{ person.person.name }}"/> + <a href="{{ person_page.url }}" class="avatar badge__avatar avatar--sm"> + {% image person_page.profile_photo max-80x80 as profile_img %} + <img src="{% firstof person_page.person.portrait profile_img.url %}" alt="{{ person_page.person.name }}"/> </a> <div class="badge__body"> <h2 class="head-heavy-xs badge__title"> - <a href="{{ person.url }}" title="{{ person.person.name }}" class="content-block--nostyle"> - {{ person.person.name }} + <a href="{{ person_page.url }}" title="{{ person_page.person.name }}" class="content-block--nostyle"> + {{ person_page.person.name }} </a> </h2> <p class="badge__occupation"> {% if title %} {{ title }} {% else %} - {{ person.job_function }} + {{ person_page.job_function }} {% endif %} </p> {% if not skipcontacts %} - {% if person.person.phone %} - <a href="tel:person.person.phone" + {% if person_page.get_phone %} + <a href="tel:{{ person_page.get_phone }}" class="contact-line icon-link content-block--nostyle contact-line--responsive badge__link"> <i class="ico--phone"></i> - <span>{{ person.person.phone }}</span> + <span>{{ person_page.get_phone }}</span> + </a> + {% endif %} + {% if person_page.get_email %} + <a href="mailto:{{ person_page.get_email }}" + class="contact-line icon-link content-block--nostyle contact-line--responsive badge__link"> + <i class="ico--envelope"></i><span>{{ person_page.get_email }}</span> </a> {% endif %} - <a href="mailto:{{ person.person.email }}" - class="contact-line icon-link content-block--nostyle contact-line--responsive badge__link"> - <i class="ico--envelope"></i><span>{{ person.person.email }}</span> - </a> {% endif %} </div> </div>