diff --git a/calendar_utils/models.py b/calendar_utils/models.py index 733d1d0e60a9137d3c5a90ec15e6d1e977ef15ac..efed763d62d70fc789a55ec336612a87afd0342f 100644 --- a/calendar_utils/models.py +++ b/calendar_utils/models.py @@ -88,10 +88,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 @@ -149,26 +145,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 bee7c79c174fa263727c2422b7d9f6bdd7a8d4aa..17bbde63e932181651be2a3ac1db4d37227d4f67 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, @@ -1695,14 +1695,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 36dcbf5dad1b489fc9abbfc346372507de664a78..933b0615a5391f9407db1f067ca3a06c70935955 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 2ef00fde80648f0bcded7c820a7979e70311667c..13718a586eddf97d7ccfc9897787e7a1d6646fc3 100644 --- a/uniweb/models.py +++ b/uniweb/models.py @@ -486,14 +486,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