From 0cfb8e56dd63d84e8df95a213280282113e60139 Mon Sep 17 00:00:00 2001 From: "jindra12.underdark" <jindra12.underdark@gmail.com> Date: Fri, 14 Apr 2023 19:54:57 +0200 Subject: [PATCH] Add calendar pages --- calendar_utils/models.py | 14 ++++++++++++++ .../templates/district/district_calendar_page.html | 10 ++++++++++ .../senat_campaign_calendar_page.html | 10 ++++++++++ uniweb/templates/uniweb/uniweb_calendar_page.html | 10 ++++++++++ 4 files changed, 44 insertions(+) create mode 100644 district/templates/district/district_calendar_page.html create mode 100644 senat_campaign/templates/senat_campaign/senat_campaign_calendar_page.html create mode 100644 uniweb/templates/uniweb/uniweb_calendar_page.html diff --git a/calendar_utils/models.py b/calendar_utils/models.py index 4f29ce42..2156b539 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 00000000..22af18e4 --- /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 00000000..f3f30da8 --- /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 00000000..6825c028 --- /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 %} -- GitLab