manager: factorize appbar between date views (#75013)

This commit is contained in:
Valentin Deniaud 2023-04-17 17:31:39 +02:00
parent c603e2a180
commit 2fa8da2617
11 changed files with 26 additions and 49 deletions

View File

@ -0,0 +1,17 @@
{% extends "chrono/manager_agenda_view.html" %}
{% load i18n %}
{% block appbar %}
{% block navigation %}{% endblock %}
<span class="actions">
{% block actions %}
{% if user_can_manage %}
<a href="{{ agenda.get_settings_url }}">{% trans 'Settings' %}</a>
{% endif %}
<a href="" onclick="window.print()">{% trans 'Print' %}</a>
{% include "chrono/manager_agenda_view_buttons_fragment.html" with active=kind %}
{% endblock %}
</span>
{% endblock %}

View File

@ -1,4 +1,4 @@
{% extends "chrono/manager_agenda_view.html" %}
{% extends "chrono/manager_agenda_date_view.html" %}
{% load i18n %}
{% block bodyargs %}class="dayview"{% endblock %}
@ -8,7 +8,7 @@
<a>{{ day|date:"SHORT_DATE_FORMAT" }}</a>
{% endblock %}
{% block appbar %}
{% block navigation %}
<span class="buttons-group">
<a class="date-prev pk-button" href="{{ view.get_previous_day_url }}"><span class="sr-only">{% trans "Previous day" %}</span></a>
<a class="date-next pk-button" href="{{ view.get_next_day_url }}"><span class="sr-only">{% trans "Next day" %}</span></a>
@ -23,12 +23,4 @@
</div>
{% endwith %}
</h2>
<span class="actions">
{% block actions %}
{% if user_can_manage %}
<a href="{% url 'chrono-manager-agenda-settings' pk=agenda.id %}">{% trans 'Settings' %}</a>
{% endif %}
<a href="" onclick="window.print()">{% trans 'Print' %}</a>
{% endblock %}
</span>
{% endblock %}

View File

@ -1,4 +1,4 @@
{% extends "chrono/manager_agenda_view.html" %}
{% extends "chrono/manager_agenda_date_view.html" %}
{% load i18n %}
{% block bodyargs %}class="monthview"{% endblock %}
@ -8,7 +8,7 @@
<a>{{ view.date|date:"F Y" }}</a>
{% endblock %}
{% block appbar %}
{% block navigation %}
<span class="buttons-group">
<a class="date-prev pk-button" href="{{ view.get_previous_month_url }}"><span class="sr-only">{% trans "Previous month" %}</span></a>
<a class="date-next pk-button" href="{{ view.get_next_month_url }}"><span class="sr-only">{% trans "Next month" %}</span></a>
@ -24,12 +24,4 @@
</div>
{% endwith %}
</h2>
<span class="actions">
{% block actions %}
{% if user_can_manage %}
<a href="{{ agenda.get_settings_url }}">{% trans 'Settings' %}</a>
{% endif %}
<a href="" onclick="window.print()">{% trans 'Print' %}</a>
{% endblock %}
</span>
{% endblock %}

View File

@ -1,4 +1,4 @@
{% extends "chrono/manager_agenda_view.html" %}
{% extends "chrono/manager_agenda_date_view.html" %}
{% load i18n %}
{% block bodyargs %}class="weekview"{% endblock %}
@ -35,7 +35,7 @@
<a>{{ view.first_day|date:"F Y" }}</a>
{% endblock %}
{% block appbar %}
{% block navigation %}
<span class="buttons-group">
<a class="date-prev pk-button" href="{{ view.get_previous_week_url }}"><span class="sr-only">{% trans "Previous week" %}</span></a>
<a class="date-next pk-button" href="{{ view.get_next_week_url }}"><span class="sr-only">{% trans "Next week" %}</span></a>
@ -51,12 +51,4 @@
</div>
{% endwith %}
</h2>
<span class="actions">
{% block actions %}
{% if user_can_manage %}
<a href="{{ agenda.get_settings_url }}">{% trans 'Settings' %}</a>
{% endif %}
<a href="" onclick="window.print()">{% trans 'Print' %}</a>
{% endblock %}
</span>
{% endblock %}

View File

@ -10,7 +10,6 @@
{% endif %}
</ul>
{{ block.super }}
{% include "chrono/manager_agenda_view_buttons_fragment.html" with active='day' %}
{% endblock %}
{% block content %}

View File

@ -10,7 +10,6 @@
{% endif %}
</ul>
{{ block.super }}
{% include "chrono/manager_agenda_view_buttons_fragment.html" with active='month' %}
{% endblock %}
{% block content %}

View File

@ -10,7 +10,6 @@
{% endif %}
</ul>
{{ block.super }}
{% include "chrono/manager_agenda_view_buttons_fragment.html" with active='week' %}
{% endblock %}
{% block content %}

View File

@ -1,11 +1,6 @@
{% extends "chrono/manager_agenda_day_view.html" %}
{% load i18n %}
{% block actions %}
{{ block.super }}
{% include "chrono/manager_agenda_view_buttons_fragment.html" with active='day' %}
{% endblock %}
{% block content %}
{% for period, desk_infos in view.get_timetable_infos %}

View File

@ -1,11 +1,6 @@
{% extends "chrono/manager_agenda_month_view.html" %}
{% load i18n %}
{% block actions %}
{{ block.super }}
{% include "chrono/manager_agenda_view_buttons_fragment.html" with active='month' %}
{% endblock %}
{% block content %}
{% include "chrono/manager_meetings_agenda_week_timetable_fragment.html" %}
{% endblock %}

View File

@ -1,11 +1,6 @@
{% extends "chrono/manager_agenda_week_view.html" %}
{% load i18n %}
{% block actions %}
{{ block.super }}
{% include "chrono/manager_agenda_view_buttons_fragment.html" with active='week' %}
{% endblock %}
{% block content %}
{% include "chrono/manager_meetings_agenda_week_timetable_fragment.html" %}
{% endblock %}

View File

@ -1299,6 +1299,7 @@ class AgendaDateView(DateMixin, ViewableAgendaMixin):
def get_context_data(self, **kwargs):
context = super().get_context_data(**kwargs)
context['agenda'] = self.agenda
context['kind'] = self.kind
if self.agenda.kind != 'events':
try:
context['hour_span'] = max(60 // self.agenda.get_base_meeting_duration(), 1)
@ -1342,6 +1343,8 @@ class AgendaDateView(DateMixin, ViewableAgendaMixin):
class AgendaDayView(AgendaDateView, DayArchiveView):
kind = 'day'
def get_queryset(self):
qs = super().get_queryset()
if self.agenda.kind != 'events':
@ -1516,7 +1519,6 @@ class AgendaWeekMonthMixin:
).all()
else:
context['single_desk'] = bool(len(self.agenda.prefetched_desks) == 1)
context['kind'] = self.kind
return context
def get_timetable_infos(self):