Skip to content
Snippets Groups Projects
Commit 0083b242 authored by Ondrej Rehounek's avatar Ondrej Rehounek
Browse files

district: Person page

parent 8700afb9
Branches
No related tags found
2 merge requests!418Release,!414district and region modules
Pipeline #6120 passed
# Generated by Django 3.2.8 on 2021-11-18 07:18
import django.db.models.deletion
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
("wagtailimages", "0023_add_choose_permissions"),
("district", "0011_auto_20211117_2136"),
]
operations = [
migrations.AddField(
model_name="districtpersonpage",
name="background_photo",
field=models.ForeignKey(
blank=True,
null=True,
on_delete=django.db.models.deletion.PROTECT,
related_name="+",
to="wagtailimages.image",
),
),
migrations.AddField(
model_name="districtpersonpage",
name="email",
field=models.EmailField(
blank=True, max_length=254, null=True, verbose_name="Email"
),
),
migrations.AddField(
model_name="districtpersonpage",
name="is_pirate",
field=models.BooleanField(
default=True, verbose_name="Je členem Pirátské strany?"
),
),
migrations.AddField(
model_name="districtpersonpage",
name="job",
field=models.CharField(
blank=True, max_length=64, null=True, verbose_name="Povolání/pozice"
),
),
migrations.AddField(
model_name="districtpersonpage",
name="phone",
field=models.EmailField(
blank=True, max_length=254, null=True, verbose_name="Telefon"
),
),
migrations.AddField(
model_name="districtpersonpage",
name="profile_photo",
field=models.ForeignKey(
blank=True,
null=True,
on_delete=django.db.models.deletion.PROTECT,
related_name="+",
to="wagtailimages.image",
),
),
]
# Generated by Django 3.2.8 on 2021-11-18 07:24
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
("district", "0012_auto_20211118_0818"),
]
operations = [
migrations.AddField(
model_name="districtpersonpage",
name="job_function",
field=models.CharField(
blank=True,
help_text="Např. 'Předseda'",
max_length=64,
null=True,
verbose_name="Funkce",
),
),
migrations.AlterField(
model_name="districtpersonpage",
name="job",
field=models.CharField(
blank=True,
help_text="Např. 'Informatik'",
max_length=64,
null=True,
verbose_name="Povolání",
),
),
migrations.AlterField(
model_name="districtpersonpage",
name="phone",
field=models.CharField(
blank=True, max_length=16, null=True, verbose_name="Telefon"
),
),
]
# Generated by Django 3.2.8 on 2021-11-18 07:35
import django.db.models.deletion
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
("wagtailimages", "0023_add_choose_permissions"),
("district", "0013_auto_20211118_0824"),
]
operations = [
migrations.AddField(
model_name="districthomepage",
name="fallback_image",
field=models.ForeignKey(
null=True,
on_delete=django.db.models.deletion.PROTECT,
related_name="+",
to="wagtailimages.image",
),
),
]
...@@ -15,6 +15,7 @@ from wagtail.admin.edit_handlers import ( ...@@ -15,6 +15,7 @@ from wagtail.admin.edit_handlers import (
from wagtail.core import blocks from wagtail.core import blocks
from wagtail.core.fields import RichTextField, StreamField from wagtail.core.fields import RichTextField, StreamField
from wagtail.core.models import Page from wagtail.core.models import Page
from wagtail.images.edit_handlers import ImageChooserPanel
from wagtailmetadata.models import MetadataPageMixin from wagtailmetadata.models import MetadataPageMixin
from calendar_utils.models import CalendarMixin from calendar_utils.models import CalendarMixin
...@@ -89,6 +90,12 @@ class DistrictHomePage(MetadataPageMixin, CalendarMixin, Page): ...@@ -89,6 +90,12 @@ class DistrictHomePage(MetadataPageMixin, CalendarMixin, Page):
matomo_id = models.IntegerField( matomo_id = models.IntegerField(
"Matomo ID pro sledování návštěvnosti", blank=True, null=True "Matomo ID pro sledování návštěvnosti", blank=True, null=True
) )
fallback_image = models.ForeignKey(
"wagtailimages.Image",
on_delete=models.PROTECT,
null=True,
related_name="+",
)
### PANELS ### PANELS
...@@ -136,6 +143,7 @@ class DistrictHomePage(MetadataPageMixin, CalendarMixin, Page): ...@@ -136,6 +143,7 @@ class DistrictHomePage(MetadataPageMixin, CalendarMixin, Page):
], ],
gettext_lazy("Nastavení lišty s kalendářem a mapou"), gettext_lazy("Nastavení lišty s kalendářem a mapou"),
), ),
ImageChooserPanel("fallback_image"),
CommentPanel(), CommentPanel(),
] ]
...@@ -388,10 +396,35 @@ class DistrictPersonTag(TaggedItemBase): ...@@ -388,10 +396,35 @@ class DistrictPersonTag(TaggedItemBase):
class DistrictPersonPage(SubpageMixin, MetadataPageMixin, Page): class DistrictPersonPage(SubpageMixin, MetadataPageMixin, Page):
### FIELDS ### FIELDS
job = models.CharField(
"Povolání", max_length=64, blank=True, null=True, help_text="Např. 'Informatik'"
)
job_function = models.CharField(
"Funkce", max_length=64, blank=True, null=True, help_text="Např. 'Předseda'"
)
perex = models.TextField("Perex osoby", blank=True) perex = models.TextField("Perex osoby", blank=True)
background_photo = models.ForeignKey(
"wagtailimages.Image",
on_delete=models.PROTECT,
blank=True,
null=True,
related_name="+",
)
profile_photo = models.ForeignKey(
"wagtailimages.Image",
on_delete=models.PROTECT,
blank=True,
null=True,
related_name="+",
)
person = models.ForeignKey(Person, on_delete=models.PROTECT, null=True) person = models.ForeignKey(Person, on_delete=models.PROTECT, null=True)
text = RichTextField("text", blank=True, features=RICH_TEXT_FEATURES) text = RichTextField("text", blank=True, features=RICH_TEXT_FEATURES)
# Fallbackové hodnoty pro data získávana z API (viz Person model)
email = models.EmailField("Email", blank=True, null=True)
phone = models.CharField("Telefon", max_length=16, blank=True, null=True)
is_pirate = models.BooleanField("Je členem Pirátské strany?", default=True)
facebook_url = models.URLField("Odkaz na Facebook", blank=True, null=True) facebook_url = models.URLField("Odkaz na Facebook", blank=True, null=True)
instagram_url = models.URLField("Odkaz na Instagram", blank=True, null=True) instagram_url = models.URLField("Odkaz na Instagram", blank=True, null=True)
twitter_url = models.URLField("Odkaz na Twitter", blank=True, null=True) twitter_url = models.URLField("Odkaz na Twitter", blank=True, null=True)
...@@ -402,16 +435,33 @@ class DistrictPersonPage(SubpageMixin, MetadataPageMixin, Page): ...@@ -402,16 +435,33 @@ class DistrictPersonPage(SubpageMixin, MetadataPageMixin, Page):
content_panels = Page.content_panels + [ content_panels = Page.content_panels + [
FieldPanel("person"), FieldPanel("person"),
FieldPanel("job"),
FieldPanel("job_function"),
ImageChooserPanel("background_photo"),
ImageChooserPanel("profile_photo"),
FieldPanel("perex"), FieldPanel("perex"),
FieldPanel("text"), FieldPanel("text"),
] ]
settings_panels = [ settings_panels = [
FieldPanel("facebook_url"), MultiFieldPanel(
FieldPanel("instagram_url"), [
FieldPanel("twitter_url"), FieldPanel("email"),
FieldPanel("youtube_url"), FieldPanel("phone"),
FieldPanel("flickr_url"), FieldPanel("is_pirate"),
],
"Kontaktní informace",
),
MultiFieldPanel(
[
FieldPanel("facebook_url"),
FieldPanel("instagram_url"),
FieldPanel("twitter_url"),
FieldPanel("youtube_url"),
FieldPanel("flickr_url"),
],
"Sociální sítě",
),
] ]
### RELATIONS ### RELATIONS
...@@ -424,6 +474,17 @@ class DistrictPersonPage(SubpageMixin, MetadataPageMixin, Page): ...@@ -424,6 +474,17 @@ class DistrictPersonPage(SubpageMixin, MetadataPageMixin, Page):
class Meta: class Meta:
verbose_name = "Detail osoby" verbose_name = "Detail osoby"
def get_background_photo(self):
"""
Vrací background_photo pro pozadí na stránce, pokud není nastaveno,
vezme falbback z homepage
"""
return (
self.background_photo
if self.background_photo
else self.root_page.fallback_image
)
@property @property
def pageperex(self): def pageperex(self):
""" """
......
...@@ -2,15 +2,20 @@ ...@@ -2,15 +2,20 @@
{% load wagtailcore_tags wagtailimages_tags shared_filters %} {% load wagtailcore_tags wagtailimages_tags shared_filters %}
{% block subheader %} {% block subheader %}
{% image page.get_background_photo width-1920 as bg_img %}
<header class="hero hero--image pt-16 pb-24 lg:pt-32 pb-24 candidate-detail__hero" <header class="hero hero--image pt-16 pb-24 lg:pt-32 pb-24 candidate-detail__hero"
style="--image-url: url(https://roznov.pirati.cz/assets/articles/2020/kampan20/zahajenikampan1-067fb446ec8933ae14591cbc29fc53ebb3009e4185900838bfb94752addbfa7b.jpg)" style="--image-url: url({{ bg_img.url }})"
> >
<div class="container container--default py-2"> <div class="container container--default py-2">
<h1 class="head-alt-md md:head-alt-lg max-w-2xl text-left lg:text-left px-4"> <h1 class="head-alt-md md:head-alt-lg max-w-2xl text-left lg:text-left px-4">
<span class="academic-title-name">{{ page.name }}</span> <span class="academic-title-name">
{{ page.title }}
</span>
</h1> </h1>
<h2 class="head-xs mt-2 max-w-xl mx-auto text-center lg:text-left"></h2> <h2 class="head-xs mt-2 max-w-xl mx-auto text-center lg:text-left">
{{ page.job }}
</h2>
</div> </div>
</header> </header>
{% endblock %} {% endblock %}
...@@ -30,7 +35,8 @@ ...@@ -30,7 +35,8 @@
<div class="card__body p-4 lg:p-8"> <div class="card__body p-4 lg:p-8">
<div class="text-center mb-8"> <div class="text-center mb-8">
<div class="avatar avatar--2xl lg:avatar--3xl avatar--bordered candidate-detail__avatar"> <div class="avatar avatar--2xl lg:avatar--3xl avatar--bordered candidate-detail__avatar">
<img src="http://placeimg.com/100/100/people" alt="Avatar"> {% image page.profile_photo max-208x208 as profile_img %}
<img src="{{ profile_img.url }}" alt="Avatar">
</div> </div>
</div> </div>
...@@ -71,13 +77,15 @@ ...@@ -71,13 +77,15 @@
</a> </a>
</div> </div>
{% endif %} {% endif %}
<div> {% if page.phone %}
<h4>Email</h4> <div>
<a href="mailto:{{ page.email }}" class="contact-line icon-link content-block--nostyle "> <h4>Email</h4>
<i class="ico--envelope"></i><span>{{ page.email }}</span> <a href="mailto:{{ page.email }}" class="contact-line icon-link content-block--nostyle ">
</a> <i class="ico--envelope"></i><span>{{ page.email }}</span>
</a>
</div>
{% endif %}
</div> </div>
</div>
<hr> <hr>
<h2>Lidé</h2> <h2>Lidé</h2>
......
{% load wagtailimages_tags %}
<div class="badge "> <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>
<a href="{{ person.url }}" class="avatar badge__avatar avatar--sm"> <div class="badge__body">
<img src="{{ person.person.portrait }}" alt="{{ person.person.name }}" /> <h2 class="head-heavy-xs badge__title">
<a href="{{ person.url }}" title="{{ person.person.name }}" class="content-block--nostyle">
{{ person.person.name }}
</a> </a>
</h2>
<div class="badge__body"> <p class="badge__occupation">
<h2 class="head-heavy-xs badge__title"> {% if title %}
<a href="{{ person.url }}" title="{{ person.person.name }}" class="content-block--nostyle"> {{ title }}
{{ person.person.name }} {% else %}
</a> {{ person.job_function }}
</h2> {% endif %}
<p class="badge__occupation"> </p>
{% if title %} {% if not skipcontacts %}
{{ title }} {% if person.person.phone %}
{% else %} <a href="tel:person.person.phone"
{{ person.pageperex|linebreaksbr }} class="contact-line icon-link content-block--nostyle contact-line--responsive badge__link">
{% endif %} <i class="ico--phone"></i>
</p> <span>{{ person.person.phone }}</span>
{% if not skipcontacts %} </a>
{% if person.person.phone %} {% endif %}
<a href="tel:person.person.phone" class="contact-line icon-link content-block--nostyle contact-line--responsive badge__link" > <a href="mailto:{{ person.person.email }}"
<i class="ico--phone"></i> class="contact-line icon-link content-block--nostyle contact-line--responsive badge__link">
<span>{{ person.person.phone }}</span> <i class="ico--envelope"></i><span>{{ person.person.email }}</span>
</a> </a>
{% endif %} {% endif %}
<a href="mailto:{{person.person.email}}" class="contact-line icon-link content-block--nostyle contact-line--responsive badge__link" > </div>
<i class="ico--envelope"></i><span>{{person.person.email}}</span> </div>
</a>
{% endif %}
</div>
</div>
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment