Skip to content
Snippets Groups Projects
Commit b5aa5dab authored by jan.bednarik's avatar jan.bednarik
Browse files

district: Allow copying people

parent df3d6e6e
No related branches found
No related tags found
2 merge requests!644district: Allow copying people,!643district: Allow copying people
Pipeline #10283 passed
...@@ -21,7 +21,6 @@ from wagtail.admin.edit_handlers import ( ...@@ -21,7 +21,6 @@ from wagtail.admin.edit_handlers import (
PageChooserPanel, PageChooserPanel,
TabbedInterface, TabbedInterface,
) )
from wagtail.admin.forms import WagtailAdminPageForm
from wagtail.contrib.routable_page.models import RoutablePageMixin, route from wagtail.contrib.routable_page.models import RoutablePageMixin, route
from wagtail.core.fields import RichTextField, StreamField from wagtail.core.fields import RichTextField, StreamField
from wagtail.core.models import Orderable, Page from wagtail.core.models import Orderable, Page
...@@ -357,7 +356,7 @@ class DistrictArticlePage( ...@@ -357,7 +356,7 @@ class DistrictArticlePage(
blank=True, blank=True,
null=True, null=True,
verbose_name="náhledový obrázek", verbose_name="náhledový obrázek",
related_name="thumb_image" related_name="thumb_image",
) )
### PANELS ### PANELS
...@@ -366,7 +365,7 @@ class DistrictArticlePage( ...@@ -366,7 +365,7 @@ class DistrictArticlePage(
FieldPanel("author_page"), FieldPanel("author_page"),
FieldPanel("is_black"), FieldPanel("is_black"),
FieldPanel("tags"), FieldPanel("tags"),
FieldPanel("thumb_image") FieldPanel("thumb_image"),
] ]
promote_panels = make_promote_panels( promote_panels = make_promote_panels(
...@@ -578,26 +577,10 @@ class DistrictPersonTag(TaggedItemBase): ...@@ -578,26 +577,10 @@ class DistrictPersonTag(TaggedItemBase):
) )
class DistrictPersonPageForm(WagtailAdminPageForm):
def clean(self):
cleaned_data = super().clean()
email = cleaned_data.get("email", None)
if email:
pages_with_email = DistrictPersonPage.objects.filter(email=email)
num_pages_with_email = len(pages_with_email)
if num_pages_with_email > 1 or (
num_pages_with_email == 1 and pages_with_email[0] != self.instance
):
raise ValidationError({"email": "Stránka s tímto emailem již existuje"})
return cleaned_data
class DistrictPersonPage( class DistrictPersonPage(
ExtendedMetadataPageMixin, SubpageMixin, MetadataPageMixin, Page ExtendedMetadataPageMixin, SubpageMixin, MetadataPageMixin, Page
): ):
### FIELDS ### FIELDS
base_form_class = DistrictPersonPageForm
job = models.CharField( job = models.CharField(
"Povolání", "Povolání",
max_length=128, max_length=128,
...@@ -941,7 +924,7 @@ class DistrictElectionCampaignPage(DistrictElectionBasePage): ...@@ -941,7 +924,7 @@ class DistrictElectionCampaignPage(DistrictElectionBasePage):
show_program_points_inline = models.BooleanField( show_program_points_inline = models.BooleanField(
"Zobrazit obsah programu na jedné stránce", "Zobrazit obsah programu na jedné stránce",
default=False, default=False,
help_text="Hodí se v případě spousty krátkých bodů programu, z nichž si většina nezaslouží vlastní stránku." help_text="Hodí se v případě spousty krátkých bodů programu, z nichž si většina nezaslouží vlastní stránku.",
) )
hero_headline = models.CharField( hero_headline = models.CharField(
"Banner headline", "Banner headline",
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment