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

district: Person page

parent 8700afb9
No related branches found
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 (
from wagtail.core import blocks
from wagtail.core.fields import RichTextField, StreamField
from wagtail.core.models import Page
from wagtail.images.edit_handlers import ImageChooserPanel
from wagtailmetadata.models import MetadataPageMixin
from calendar_utils.models import CalendarMixin
......@@ -89,6 +90,12 @@ class DistrictHomePage(MetadataPageMixin, CalendarMixin, Page):
matomo_id = models.IntegerField(
"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
......@@ -136,6 +143,7 @@ class DistrictHomePage(MetadataPageMixin, CalendarMixin, Page):
],
gettext_lazy("Nastavení lišty s kalendářem a mapou"),
),
ImageChooserPanel("fallback_image"),
CommentPanel(),
]
......@@ -388,10 +396,35 @@ class DistrictPersonTag(TaggedItemBase):
class DistrictPersonPage(SubpageMixin, MetadataPageMixin, Page):
### 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)
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)
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)
instagram_url = models.URLField("Odkaz na Instagram", blank=True, null=True)
twitter_url = models.URLField("Odkaz na Twitter", blank=True, null=True)
......@@ -402,16 +435,33 @@ class DistrictPersonPage(SubpageMixin, MetadataPageMixin, Page):
content_panels = Page.content_panels + [
FieldPanel("person"),
FieldPanel("job"),
FieldPanel("job_function"),
ImageChooserPanel("background_photo"),
ImageChooserPanel("profile_photo"),
FieldPanel("perex"),
FieldPanel("text"),
]
settings_panels = [
MultiFieldPanel(
[
FieldPanel("email"),
FieldPanel("phone"),
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
......@@ -424,6 +474,17 @@ class DistrictPersonPage(SubpageMixin, MetadataPageMixin, Page):
class Meta:
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
def pageperex(self):
"""
......
......@@ -2,15 +2,20 @@
{% load wagtailcore_tags wagtailimages_tags shared_filters %}
{% 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"
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">
<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>
<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>
</header>
{% endblock %}
......@@ -30,7 +35,8 @@
<div class="card__body p-4 lg:p-8">
<div class="text-center mb-8">
<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>
......@@ -71,12 +77,14 @@
</a>
</div>
{% endif %}
{% if page.phone %}
<div>
<h4>Email</h4>
<a href="mailto:{{ page.email }}" class="contact-line icon-link content-block--nostyle ">
<i class="ico--envelope"></i><span>{{ page.email }}</span>
</a>
</div>
{% endif %}
</div>
<hr>
......
{% load wagtailimages_tags %}
<div class="badge ">
<a href="{{ person.url }}" class="avatar badge__avatar avatar--sm">
<img src="{{ person.person.portrait }}" alt="{{ person.person.name }}" />
{% image person.profile_photo max-80x80 as profile_img %}
<img src="{% firstof person.person.portrait profile_img.url %}" alt="{{ person.person.name }}"/>
</a>
<div class="badge__body">
......@@ -15,20 +16,21 @@
{% if title %}
{{ title }}
{% else %}
{{ person.pageperex|linebreaksbr }}
{{ person.job_function }}
{% endif %}
</p>
{% if not skipcontacts %}
{% if person.person.phone %}
<a href="tel:person.person.phone" class="contact-line icon-link content-block--nostyle contact-line--responsive badge__link" >
<a href="tel:person.person.phone"
class="contact-line icon-link content-block--nostyle contact-line--responsive badge__link">
<i class="ico--phone"></i>
<span>{{ person.person.phone }}</span>
</a>
{% endif %}
<a href="mailto:{{person.person.email}}" class="contact-line icon-link content-block--nostyle contact-line--responsive badge__link" >
<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>
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment