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

Display all events if fullscreen

parent 0cfb8e56
Branches
No related tags found
2 merge requests!804Release,!751Add calendar page with link from calendar display
......@@ -99,6 +99,10 @@ class CalendarMixin(models.Model):
blank=True,
)
@property
def first_calendar_page(self):
return self._first_subpage_of_type(CalendarPage)
class Meta:
abstract = True
......@@ -195,8 +199,14 @@ class CalendarPage(SubpageMixin, MetadataPageMixin, CalendarMixin, Page):
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"
return str(
Path(
project,
pathname,
"templates",
pathname,
pathname + "_calendar_page.html",
)
)
class Meta:
......
from django import template
register = template.Library()
def event_list(calendar, full_list):
"""
Outputs a list of events, in case the calendar is on calendar page, it will print all future events,
otherwise will print only a fraction
"""
return calendar.future_events if full_list else calendar.current_events
register.filter("event_list", event_list)
......@@ -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
from calendar_utils.models import CalendarMixin, CalendarPage
from maps_utils.blocks import MapPointBlock
from maps_utils.const import (
DEFAULT_MAP_STYLE,
......
{% load event_list %}
{% if page.root_page.has_calendar %}
<div class="calendar grid grid-cols-4">
<div class="col-span-4 xl:col-span-1">
<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 }}">
<button class="btn btn--white btn--fullwidth sm:btn--autowidth mt-8">
{{ event }}
<div class="btn__body">Zobrazit další</div>
</button>
</a>
{% endif %}
</div>
</aside>
</div>
<div class="col-span-4 xl:col-span-3">
{% for event in page.root_page.calendar.current_events %}
{% with full_list=fullscreen %}
{% with events=page.root_page.calendar|event_list:full_list %}
{% for event in events %}
<div class="grid grid-cols-12 items-center calendar-table-row">
<div class="col-span-2 text-orange-300 head-alt-md calendar-table-row__col">
<span>{{ event.start|date:"j." }}</span>
......@@ -62,6 +68,8 @@
<p>Žádné události.</p>
</div>
{% endfor %}
{% endwith %}
{% endwith %}
</div>
</div>
{% else %}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment