diff --git a/calendar_utils/models.py b/calendar_utils/models.py index c6e6045537bd862d4fb7588a355967b079e34ee7..6327c8c389cedb649484cc6cb307c01e57558076 100644 --- a/calendar_utils/models.py +++ b/calendar_utils/models.py @@ -79,10 +79,6 @@ class CalendarMixin(models.Model): Calendar, null=True, blank=True, on_delete=models.PROTECT ) - @property - def first_calendar_page(self): - return self._first_subpage_of_type(CalendarPageMixin) - class Meta: abstract = True @@ -108,26 +104,3 @@ class CalendarMixin(models.Model): self.calendar = None super().save(*args, **kwargs) - - -class CalendarPageMixin(CalendarMixin): - """ - Page mixin for displaying full calendar - """ - - calendar_url = models.URLField( - "URL kalendáře ve formátu iCal", blank=False, null=True - ) - - ### PANELS - - content_panels = [ - FieldPanel("calendar_url"), - ] - - ### RELATIONS - - subpage_types = [] - - class Meta: - abstract = True diff --git a/district/migrations/0109_districtcalendarpage_and_more.py b/district/migrations/0109_districtcalendarpage_and_more.py index 468fe20fc347018041b8569eda497c131381eb5a..e9d7d78d60cfd4ff93d2bd741a634917f45bf474 100644 --- a/district/migrations/0109_districtcalendarpage_and_more.py +++ b/district/migrations/0109_districtcalendarpage_and_more.py @@ -1,4 +1,4 @@ -# Generated by Django 4.1.8 on 2023-04-14 23:48 +# Generated by Django 4.1.8 on 2023-04-27 18:52 import django.db.models.deletion import wagtailmetadata.models @@ -9,9 +9,9 @@ import shared.models class Migration(migrations.Migration): dependencies = [ - ("wagtailimages", "0025_alter_image_file_alter_rendition_file"), - ("wagtailcore", "0083_workflowcontenttype"), ("calendar_utils", "0004_auto_20220505_1228"), + ("wagtailcore", "0083_workflowcontenttype"), + ("wagtailimages", "0025_alter_image_file_alter_rendition_file"), ("district", "0108_alter_districtcenterpage_content_and_more"), ] @@ -33,7 +33,9 @@ class Migration(migrations.Migration): ( "calendar_url", models.URLField( - null=True, verbose_name="URL kalendáře ve formátu iCal" + blank=True, + null=True, + verbose_name="URL kalendáře ve formátu iCal", ), ), ( diff --git a/district/models.py b/district/models.py index cb55d0d945008430a1e13b7bdd22476edda75db4..2892ad900dac41f70e9b0f9b2c93dcffc515dea8 100644 --- a/district/models.py +++ b/district/models.py @@ -26,7 +26,7 @@ from wagtail.fields import RichTextField, StreamField from wagtail.models import Orderable, Page from wagtailmetadata.models import MetadataPageMixin -from calendar_utils.models import CalendarMixin, CalendarPageMixin +from calendar_utils.models import CalendarMixin from maps_utils.blocks import MapPointBlock from maps_utils.const import ( DEFAULT_MAP_STYLE, @@ -1638,14 +1638,14 @@ def make_feature_index_cache_key(feature: "DistrictGeoFeatureDetailPage"): return f"DistrictGeoFeatureDetailPage::{feature.id}::index" -class DistrictCalendarPage(SubpageMixin, MetadataPageMixin, CalendarPageMixin, Page): +class DistrictCalendarPage(SubpageMixin, MetadataPageMixin, CalendarMixin, Page): """ Page for displaying full calendar """ ### PANELS - content_panels = Page.content_panels + CalendarPageMixin.content_panels + content_panels = Page.content_panels + [FieldPanel("calendar_url")] ### RELATIONS diff --git a/shared/templates/shared/calendar_current_events_snippet.html b/shared/templates/shared/calendar_current_events_snippet.html index 2475677f03d59d4f87d343389a34496b9dec40b3..a54faa6f425ebe13f3e7a34c93240fec70ae627e 100644 --- a/shared/templates/shared/calendar_current_events_snippet.html +++ b/shared/templates/shared/calendar_current_events_snippet.html @@ -5,8 +5,8 @@ <aside class="banner bg-orange-300 text-white h-full"> <i class="ico--calendar banner__icon"></i> <div class="banner__body"><h1 class="head-alt-md banner__cta">Kalendář</h1> - {% if not fullscreen and page.root_page.first_calendar_page %} - <a href="{{ page.root_page.first_calendar_page.url }}"> + {% if not fullscreen and page.calendar_page %} + <a href="{{ page.calendar_page.url }}"> <button class="btn btn--white btn--fullwidth sm:btn--autowidth mt-8"> <div class="btn__body">Zobrazit další</div> </button> diff --git a/uniweb/migrations/0042_uniwebcalendarpage_uniwebhomepage_calendar_page.py b/uniweb/migrations/0042_uniwebcalendarpage_uniwebhomepage_calendar_page.py index 1a80559648f39f50f4a0f0c1c97808008c15ea7d..dd100b5c36c825465dace273585417cc9d3eb969 100644 --- a/uniweb/migrations/0042_uniwebcalendarpage_uniwebhomepage_calendar_page.py +++ b/uniweb/migrations/0042_uniwebcalendarpage_uniwebhomepage_calendar_page.py @@ -1,4 +1,4 @@ -# Generated by Django 4.1.8 on 2023-04-14 23:48 +# Generated by Django 4.1.8 on 2023-04-27 18:52 import django.db.models.deletion import wagtailmetadata.models @@ -9,9 +9,9 @@ import shared.models class Migration(migrations.Migration): dependencies = [ - ("wagtailimages", "0025_alter_image_file_alter_rendition_file"), - ("wagtailcore", "0083_workflowcontenttype"), ("calendar_utils", "0004_auto_20220505_1228"), + ("wagtailcore", "0083_workflowcontenttype"), + ("wagtailimages", "0025_alter_image_file_alter_rendition_file"), ("uniweb", "0041_alter_uniwebflexiblepage_content_and_more"), ] @@ -33,7 +33,9 @@ class Migration(migrations.Migration): ( "calendar_url", models.URLField( - null=True, verbose_name="URL kalendáře ve formátu iCal" + blank=True, + null=True, + verbose_name="URL kalendáře ve formátu iCal", ), ), ( diff --git a/uniweb/models.py b/uniweb/models.py index 6569f8bf2ec2dc3b883355bb528c03fbee4b6bc0..434c09631e8d8fa80b8ce946722fa458861d2437 100644 --- a/uniweb/models.py +++ b/uniweb/models.py @@ -1,3 +1,5 @@ +import random + from captcha.fields import CaptchaField from django import forms from django.core.paginator import Paginator @@ -23,7 +25,7 @@ from wagtail.images.blocks import ImageChooserBlock from wagtail.models import Page from wagtailmetadata.models import MetadataPageMixin -from calendar_utils.models import CalendarMixin, CalendarPageMixin +from calendar_utils.models import CalendarMixin from shared.blocks import ChartBlock from shared.const import RICH_TEXT_DEFAULT_FEATURES from shared.models import ( @@ -32,7 +34,7 @@ from shared.models import ( ExtendedMetadataPageMixin, SubpageMixin, ) -from shared.utils import make_promote_panels +from shared.utils import make_promote_panels, strip_all_html_tags, trim_to_length from tuning import admin_help from .blocks import PeopleGroupListBlock, PersonUrlBlock @@ -455,14 +457,14 @@ class UniwebFlexiblePage( verbose_name = "Flexibilní stránka" -class UniwebCalendarPage(SubpageMixin, MetadataPageMixin, CalendarPageMixin, Page): +class UniwebCalendarPage(SubpageMixin, MetadataPageMixin, CalendarMixin, Page): """ Page for displaying full calendar """ ### PANELS - content_panels = Page.content_panels + CalendarPageMixin.content_panels + content_panels = Page.content_panels + [FieldPanel("calendar_url")] ### RELATIONS