work on dated sections
This commit is contained in:
		@ -666,6 +666,7 @@ class DatedListPage(DatedListBase,Page):
 | 
			
		||||
 | 
			
		||||
        # queryset
 | 
			
		||||
        context['object_list'] = self.get_queryset(request, context)
 | 
			
		||||
        context['target'] = self
 | 
			
		||||
        return context
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -982,7 +982,21 @@ class SectionTimetable(SectionItem,DatedListBase):
 | 
			
		||||
        verbose_name = _('Section: 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):
 | 
			
		||||
        from aircox_cms.models import DiffusionPage
 | 
			
		||||
@ -995,8 +1009,10 @@ class SectionTimetable(SectionItem,DatedListBase):
 | 
			
		||||
 | 
			
		||||
    def get_context(self, request, page):
 | 
			
		||||
        context = super().get_context(request, page)
 | 
			
		||||
        context.update(self.get_date_context())
 | 
			
		||||
        if self.nav_visible:
 | 
			
		||||
            context.update(self.get_date_context())
 | 
			
		||||
        context['object_list'] = self.get_queryset(context)
 | 
			
		||||
        context['target'] = self.timetable_page
 | 
			
		||||
        return context
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -20,7 +20,7 @@
 | 
			
		||||
    {% if page.summary %}
 | 
			
		||||
        {{ page.summary }}
 | 
			
		||||
    {% else %}
 | 
			
		||||
        {{ page.body|richtext|truncatewords:24 }}
 | 
			
		||||
        {{ page.body|truncatewords:24|richtext }}
 | 
			
		||||
    {% endif %}
 | 
			
		||||
</section>
 | 
			
		||||
{% endblock %}
 | 
			
		||||
 | 
			
		||||
@ -4,10 +4,14 @@
 | 
			
		||||
<div class="list date_list">
 | 
			
		||||
{% if 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 %}
 | 
			
		||||
    <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 %}
 | 
			
		||||
 | 
			
		||||
    {% for day in nav_dates.dates %}
 | 
			
		||||
@ -20,8 +24,8 @@
 | 
			
		||||
    </a>
 | 
			
		||||
    {% endfor %}
 | 
			
		||||
 | 
			
		||||
    {% if nav_dates.next %}
 | 
			
		||||
    <a href="?date={{ nav_dates.next|date:"Y-m-d" }}" title="{% trans "next days" %}">▶</a>
 | 
			
		||||
    {% if target and nav_dates.next %}
 | 
			
		||||
    <a href="{{ target.url }}?date={{ nav_dates.next|date:"Y-m-d" }}" title="{% trans "next days" %}">▶</a>
 | 
			
		||||
    {% endif %}
 | 
			
		||||
</nav>
 | 
			
		||||
{% endif %}
 | 
			
		||||
 | 
			
		||||
		Reference in New Issue
	
	Block a user