manager: display exceptions in events month view (#52115)
This commit is contained in:
parent
c68902b967
commit
6c89beb1fb
|
@ -18,8 +18,12 @@
|
|||
<div>
|
||||
{% if object_list %}
|
||||
<ul class="objects-list single-links">
|
||||
{% for event in object_list %}
|
||||
{% include 'chrono/manager_agenda_event_fragment.html' %}
|
||||
{% for object in object_list %}
|
||||
{% if object.is_exception %}
|
||||
<li><a class="disabled">{% trans "Exception:"%} {{ object }}</a></li>
|
||||
{% else %}
|
||||
{% include 'chrono/manager_agenda_event_fragment.html' with event=object %}
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
</ul>
|
||||
{% include "gadjo/pagination.html" %}
|
||||
|
|
|
@ -1212,6 +1212,10 @@ class AgendaMonthView(AgendaDateView, MonthArchiveView):
|
|||
object_list = self.agenda.add_event_recurrences(
|
||||
object_list, min_start, max_start, include_cancelled=True
|
||||
)
|
||||
exceptions = TimePeriodException.objects.filter(
|
||||
desk__agenda=self.agenda, start_datetime__gte=min_start, end_datetime__lt=max_start
|
||||
).annotate(is_exception=Value(True, BooleanField()))
|
||||
object_list = sorted(itertools.chain(object_list, exceptions), key=lambda x: x.start_datetime)
|
||||
return date_list, object_list, extra_context
|
||||
|
||||
def get_template_names(self):
|
||||
|
|
|
@ -2680,7 +2680,7 @@ def test_agenda_events_month_view(app, admin_user):
|
|||
|
||||
with CaptureQueriesContext(connection) as ctx:
|
||||
resp = app.get('/manage/agendas/%s/%s/%s/' % (agenda.id, 2020, 11))
|
||||
assert len(ctx.captured_queries) == 8
|
||||
assert len(ctx.captured_queries) == 9
|
||||
assert len(resp.pyquery.find('.event-info')) == 5
|
||||
assert 'abc' in resp.pyquery.find('.event-info')[0].text
|
||||
assert 'abc' in resp.pyquery.find('.event-info')[1].text
|
||||
|
@ -2688,6 +2688,17 @@ def test_agenda_events_month_view(app, admin_user):
|
|||
assert 'abc' in resp.pyquery.find('.event-info')[3].text
|
||||
assert 'abc' in resp.pyquery.find('.event-info')[4].text
|
||||
|
||||
time_period_exception = TimePeriodException.objects.create(
|
||||
desk=agenda.desk_set.get(),
|
||||
start_datetime=start_datetime + datetime.timedelta(days=6),
|
||||
end_datetime=start_datetime + datetime.timedelta(days=8),
|
||||
)
|
||||
resp = app.get('/manage/agendas/%s/%s/%s/' % (agenda.id, 2020, 11))
|
||||
assert len(resp.pyquery.find('.event-info')) == 4
|
||||
assert 'abc' in resp.pyquery.find('li')[4].text_content()
|
||||
assert 'Exception: 11/10/2020' in resp.pyquery.find('li')[5].text_content()
|
||||
assert 'xyz' in resp.pyquery.find('li')[6].text_content()
|
||||
|
||||
# 12/2020 has 5 Wednesday
|
||||
resp = app.get('/manage/agendas/%s/%s/%s/' % (agenda.id, 2020, 12))
|
||||
assert len(resp.pyquery.find('.event-info')) == 5
|
||||
|
|
Loading…
Reference in New Issue