0001-manager-grab-exceptions-from-unavailability-calendar.patch
chrono/manager/templates/chrono/manager_time_period_exception_list.html | ||
---|---|---|
20 | 20 |
<ul class="objects-list single-links"> |
21 | 21 |
{% for exception in object_list %} |
22 | 22 |
<li> |
23 |
<a {% if user_can_manage and not exception.from_settings%}href="{% url 'chrono-manager-time-period-exception-edit' pk=exception.id %}"{% endif %}>{{ exception }}</a> |
|
24 |
{% if user_can_manage and not exception.from_settings%}<a rel="popup" class="delete" href="{% url 'chrono-manager-time-period-exception-delete' pk=exception.id %}{% if not page_obj %}?from_popup{% endif %}">{% trans "remove" %}</a>{% endif %} |
|
23 |
<a {% if user_can_manage and not exception.from_settings and not exception.unavailability_calendar %}href="{% url 'chrono-manager-time-period-exception-edit' pk=exception.id %}"{% endif %}>{{ exception }}</a>
|
|
24 |
{% if user_can_manage and not exception.from_settings and not exception.unavailability_calendar %}<a rel="popup" class="delete" href="{% url 'chrono-manager-time-period-exception-delete' pk=exception.id %}{% if not page_obj %}?from_popup{% endif %}">{% trans "remove" %}</a>{% endif %}
|
|
25 | 25 |
</li> |
26 | 26 |
{% endfor %} |
27 | 27 |
</ul> |
chrono/manager/views.py | ||
---|---|---|
1943 | 1943 |
paginate_by = 20 |
1944 | 1944 | |
1945 | 1945 |
def get_queryset(self): |
1946 |
return self.model.objects.filter(desk=self.desk, end_datetime__gte=now()).select_related('source') |
|
1946 |
return self.model.objects.filter( |
|
1947 |
Q(desk=self.desk) | Q(unavailability_calendar__desks=self.desk), end_datetime__gte=now() |
|
1948 |
).select_related('source') |
|
1947 | 1949 | |
1948 | 1950 |
def get_context_data(self, **kwargs): |
1949 | 1951 |
context = super(TimePeriodExceptionListView, self).get_context_data(**kwargs) |
tests/test_manager.py | ||
---|---|---|
2344 | 2344 |
app.get("/manage/time-period-exceptions/%d/exception-list" % desk.pk) |
2345 | 2345 |
assert len(ctx.captured_queries) == 6 |
2346 | 2346 | |
2347 |
# add an unavailability calendar |
|
2348 |
unavailability_calendar = UnavailabilityCalendar.objects.create(label='calendar') |
|
2349 |
past_exception = TimePeriodException.objects.create( |
|
2350 |
label='Calendar Past Exception', |
|
2351 |
unavailability_calendar=unavailability_calendar, |
|
2352 |
start_datetime=now() - datetime.timedelta(days=2), |
|
2353 |
end_datetime=now() - datetime.timedelta(days=1), |
|
2354 |
) |
|
2355 |
current_exception = TimePeriodException.objects.create( |
|
2356 |
label='Calendar Current Exception', |
|
2357 |
unavailability_calendar=unavailability_calendar, |
|
2358 |
start_datetime=now() - datetime.timedelta(days=1), |
|
2359 |
end_datetime=now() + datetime.timedelta(days=1), |
|
2360 |
) |
|
2361 |
future_exception = TimePeriodException.objects.create( |
|
2362 |
label='Calendar Future Exception', |
|
2363 |
unavailability_calendar=unavailability_calendar, |
|
2364 |
start_datetime=now() + datetime.timedelta(days=1), |
|
2365 |
end_datetime=now() + datetime.timedelta(days=2), |
|
2366 |
) |
|
2367 |
unavailability_calendar.desks.add(desk) |
|
2368 | ||
2369 |
for url in ( |
|
2370 |
"/manage/time-period-exceptions/%d/exception-extract-list" % desk.pk, |
|
2371 |
"/manage/time-period-exceptions/%d/exception-list" % desk.pk, |
|
2372 |
): |
|
2373 |
resp = app.get(url) |
|
2374 |
assert 'Calendar Past Exception' not in resp.text |
|
2375 |
assert '/manage/time-period-exceptions/%d/edit' % past_exception.pk not in resp.text |
|
2376 |
assert 'Calendar Current Exception' in resp.text |
|
2377 |
assert '/manage/time-period-exceptions/%d/edit' % current_exception.pk not in resp.text |
|
2378 |
assert 'Calendar Future Exception' in resp.text |
|
2379 |
assert '/manage/time-period-exceptions/%d/edit' % future_exception.pk not in resp.text |
|
2380 | ||
2347 | 2381 | |
2348 | 2382 |
def test_agenda_import_time_period_exception_from_ics(app, admin_user): |
2349 | 2383 |
agenda = Agenda.objects.create(label='Example', kind='meetings') |
2350 |
- |