diff --git a/calendar_utils/models.py b/calendar_utils/models.py index 4f29ce428159bf2252a659039ebdd7804ef1c527..2156b53903eb67af0a99a8c7ceec43750cfb4116 100644 --- a/calendar_utils/models.py +++ b/calendar_utils/models.py @@ -1,6 +1,7 @@ import json import logging from datetime import date, timedelta +from pathlib import Path import arrow from django.core.serializers.json import DjangoJSONEncoder @@ -185,5 +186,18 @@ class CalendarPage(SubpageMixin, MetadataPageMixin, CalendarMixin, Page): ### OTHERS + def get_template(self, request): + """ + Allows this template to dynamically load correct calendar_page, based on root page which helps it determine from + which project the page should be loaded + """ + module = self.root_page.__class__.__module__ # Example: "district.module" + pathname = module.split(".")[0] # Gets "district" from "district.module" + root = str(Path(__file__).parents[2]) + project = root + "/majak" + return ( + project + "/" + pathname + "/templates/" + pathname + "_calendar_page.html" + ) + class Meta: verbose_name = "Stránka s kalendářem" diff --git a/district/templates/district/district_calendar_page.html b/district/templates/district/district_calendar_page.html new file mode 100644 index 0000000000000000000000000000000000000000..22af18e4bca60d4dd781c854b4110041124d5396 --- /dev/null +++ b/district/templates/district/district_calendar_page.html @@ -0,0 +1,10 @@ +{% extends "district/base.html" %} +{% load wagtailcore_tags %} + +{% block content %} +<main> + <section class="my-8 lg:my-16 container-padding--zero lg:container-padding--auto"> + {% include "shared/calendar_current_events_snippet.html" with fullscreen=True %} + </section> +</main> +{% endblock %} diff --git a/senat_campaign/templates/senat_campaign/senat_campaign_calendar_page.html b/senat_campaign/templates/senat_campaign/senat_campaign_calendar_page.html new file mode 100644 index 0000000000000000000000000000000000000000..f3f30da86b27359f9af14ba180ff7a5a8203b7fb --- /dev/null +++ b/senat_campaign/templates/senat_campaign/senat_campaign_calendar_page.html @@ -0,0 +1,10 @@ +{% extends "senat_campaign/base.html" %} +{% load wagtailcore_tags %} + +{% block content %} +<main> + <section class="my-8 lg:my-16 container-padding--zero lg:container-padding--auto"> + {% include "shared/calendar_current_events_snippet.html" with fullscreen=True %} + </section> +</main> +{% endblock %} diff --git a/uniweb/templates/uniweb/uniweb_calendar_page.html b/uniweb/templates/uniweb/uniweb_calendar_page.html new file mode 100644 index 0000000000000000000000000000000000000000..6825c028ec82ade5e6401d93d802e31c2677d791 --- /dev/null +++ b/uniweb/templates/uniweb/uniweb_calendar_page.html @@ -0,0 +1,10 @@ +{% extends "uniweb/base.html" %} +{% load wagtailcore_tags %} + +{% block content %} +<main> + <section class="my-8 lg:my-16 container-padding--zero lg:container-padding--auto"> + {% include "shared/calendar_current_events_snippet.html" with fullscreen=True %} + </section> +</main> +{% endblock %}