forked from rc/aircox
work on dated sections
This commit is contained in:
parent
9276e5007e
commit
2453613149
|
@ -666,6 +666,7 @@ class DatedListPage(DatedListBase,Page):
|
||||||
|
|
||||||
# queryset
|
# queryset
|
||||||
context['object_list'] = self.get_queryset(request, context)
|
context['object_list'] = self.get_queryset(request, context)
|
||||||
|
context['target'] = self
|
||||||
return context
|
return context
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -982,7 +982,21 @@ class SectionTimetable(SectionItem,DatedListBase):
|
||||||
verbose_name = _('Section: Timetable')
|
verbose_name = _('Section: Timetable')
|
||||||
verbose_name_plural = _('Sections: Timetable')
|
verbose_name_plural = _('Sections: Timetable')
|
||||||
|
|
||||||
panels = SectionItem.panels + DatedListBase.panels
|
target = models.ForeignKey(
|
||||||
|
'aircox_cms.TimetablePage',
|
||||||
|
verbose_name = _('timetable page'),
|
||||||
|
blank = True, null = True,
|
||||||
|
help_text = _('select a timetable page used to show complete timetable'),
|
||||||
|
)
|
||||||
|
nav_visible = models.BooleanField(
|
||||||
|
_('show date navigation'),
|
||||||
|
default = True,
|
||||||
|
help_text = _('if checked, navigation dates will be shown')
|
||||||
|
)
|
||||||
|
|
||||||
|
panels = SectionItem.panels + DatedListBase.panels + [
|
||||||
|
FieldPanel('page')
|
||||||
|
]
|
||||||
|
|
||||||
def get_queryset(self, context):
|
def get_queryset(self, context):
|
||||||
from aircox_cms.models import DiffusionPage
|
from aircox_cms.models import DiffusionPage
|
||||||
|
@ -995,8 +1009,10 @@ class SectionTimetable(SectionItem,DatedListBase):
|
||||||
|
|
||||||
def get_context(self, request, page):
|
def get_context(self, request, page):
|
||||||
context = super().get_context(request, page)
|
context = super().get_context(request, page)
|
||||||
|
if self.nav_visible:
|
||||||
context.update(self.get_date_context())
|
context.update(self.get_date_context())
|
||||||
context['object_list'] = self.get_queryset(context)
|
context['object_list'] = self.get_queryset(context)
|
||||||
|
context['target'] = self.timetable_page
|
||||||
return context
|
return context
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -20,7 +20,7 @@
|
||||||
{% if page.summary %}
|
{% if page.summary %}
|
||||||
{{ page.summary }}
|
{{ page.summary }}
|
||||||
{% else %}
|
{% else %}
|
||||||
{{ page.body|richtext|truncatewords:24 }}
|
{{ page.body|truncatewords:24|richtext }}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</section>
|
</section>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
|
@ -4,10 +4,14 @@
|
||||||
<div class="list date_list">
|
<div class="list date_list">
|
||||||
{% if nav_dates %}
|
{% if nav_dates %}
|
||||||
<nav class="nav_dates">
|
<nav class="nav_dates">
|
||||||
<a href="?date={{ nav_dates.today|date:"Y-m-d" }}" title="{% trans "go to today" %}">○</a>
|
{{ target }}
|
||||||
|
{% if target %}
|
||||||
|
<a href="{{ target.url }}?date={{ nav_dates.today|date:"Y-m-d" }}" title="{% trans "go to today" %}">○</a>
|
||||||
|
|
||||||
{% if nav_dates.prev %}
|
{% if nav_dates.prev %}
|
||||||
<a href="?date={{ nav_dates.prev|date:"Y-m-d" }}" title="{% trans "previous days" %}">◀</a>
|
<a href="{{ target.url }}?date={{ nav_dates.prev|date:"Y-m-d" }}" title="{% trans "previous days" %}">◀</a>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
{% for day in nav_dates.dates %}
|
{% for day in nav_dates.dates %}
|
||||||
|
@ -20,8 +24,8 @@
|
||||||
</a>
|
</a>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
|
||||||
{% if nav_dates.next %}
|
{% if target and nav_dates.next %}
|
||||||
<a href="?date={{ nav_dates.next|date:"Y-m-d" }}" title="{% trans "next days" %}">▶</a>
|
<a href="{{ target.url }}?date={{ nav_dates.next|date:"Y-m-d" }}" title="{% trans "next days" %}">▶</a>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</nav>
|
</nav>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user