0003-manager-display-cancelled-bookings-on-check-page-610.patch
chrono/manager/templates/chrono/manager_event_check.html | ||
---|---|---|
66 | 66 |
{% for result in results %} |
67 | 67 |
<tr class="booking"> |
68 | 68 |
{% if result.kind == 'booking' %} |
69 |
{% with result as booking %}{% include "chrono/manager_event_check_booking_fragment.html" %}{% endwith %} |
|
69 |
{% if result.cancellation_datetime is None %} |
|
70 |
{% with result as booking %}{% include "chrono/manager_event_check_booking_fragment.html" %}{% endwith %} |
|
71 |
{% else %} |
|
72 |
<td class="booking-username main-list">{{ result.get_user_block }}</td> |
|
73 |
<td class="booking-status">({% trans "Cancelled" %})</td> |
|
74 |
{% if not event.checked or not agenda.disable_check_update %} |
|
75 |
<td class="booking-actions"></td> |
|
76 |
{% endif %} |
|
77 |
{% endif %} |
|
70 | 78 |
{% elif result.kind == 'subscription' %} |
71 | 79 |
<td class="booking-username main-list">{{ result.get_user_block }}</td> |
72 | 80 |
<td class="booking-status">({% trans "Not booked" %})</td> |
... | ... | |
90 | 98 |
<table class="main check-bookings"> |
91 | 99 |
<tbody> |
92 | 100 |
{% for booking in waiting %} |
93 |
<tr><td class="booking-username waiting">{{ booking.get_user_block }}{% if booking.places_count > 1 %} ({{ booking.places_count }} {% trans "places" %}){% endif %}</td></tr> |
|
101 |
<tr> |
|
102 |
<td class="booking-username waiting">{{ booking.get_user_block }}{% if booking.places_count > 1 %} ({{ booking.places_count }} {% trans "places" %}){% endif %}</td> |
|
103 |
<td>{% if booking.cancellation_datetime %}({% trans "Cancelled" %}){% endif %}</td> |
|
104 |
</tr> |
|
94 | 105 |
{% endfor %} |
95 | 106 |
</tbody> |
96 | 107 |
</table> |
chrono/manager/views.py | ||
---|---|---|
2075 | 2075 |
event = self.object |
2076 | 2076 | |
2077 | 2077 |
# booking base queryset |
2078 |
booking_qs_kwargs = {} |
|
2079 |
if not self.agenda.cancelled_bookings_on_check_page: |
|
2080 |
booking_qs_kwargs = {'cancellation_datetime__isnull': True} |
|
2078 | 2081 |
booked_qs = event.booking_set.filter( |
2079 |
cancellation_datetime__isnull=True, in_waiting_list=False, primary_booking__isnull=True
|
|
2082 |
in_waiting_list=False, primary_booking__isnull=True, **booking_qs_kwargs
|
|
2080 | 2083 |
) |
2081 | 2084 |
booked_qs = booked_qs.annotate( |
2082 |
places_count=Value(1) |
|
2083 |
+ Count('secondary_booking_set', filter=Q(cancellation_datetime__isnull=True)) |
|
2085 |
places_count=Value(1) + Count('secondary_booking_set', filter=Q(**booking_qs_kwargs)) |
|
2084 | 2086 |
) |
2085 | 2087 | |
2086 | 2088 |
# waiting list queryset |
2087 | 2089 |
waiting_qs = event.booking_set.filter( |
2088 |
cancellation_datetime__isnull=True, in_waiting_list=True, primary_booking__isnull=True
|
|
2090 |
in_waiting_list=True, primary_booking__isnull=True, **booking_qs_kwargs
|
|
2089 | 2091 |
).order_by('user_last_name', 'user_first_name') |
2090 | 2092 |
waiting_qs = waiting_qs.annotate( |
2091 | 2093 |
places_count=Value(1) |
... | ... | |
2117 | 2119 |
results = [] |
2118 | 2120 |
booked_without_status = False |
2119 | 2121 |
for booking in booked_filterset.qs: |
2120 |
if booking.user_was_present is None: |
|
2122 |
if booking.cancellation_datetime is None and booking.user_was_present is None:
|
|
2121 | 2123 |
booked_without_status = True |
2122 | 2124 |
booking.form = BookingAbsenceReasonForm( |
2123 | 2125 |
agenda=self.agenda, initial={'reason': booking.user_absence_reason} |
tests/manager/test_event.py | ||
---|---|---|
1268 | 1268 |
event=event, user_external_id='user:5', user_first_name='User', user_last_name='05' |
1269 | 1269 |
) |
1270 | 1270 |
booking6 = Booking.objects.create( |
1271 |
event=event, user_external_id='user:6', user_first_name='User', user_last_name='Cancelled' |
|
1271 |
event=event, user_external_id='user:6', user_first_name='User', user_last_name='12 Cancelled'
|
|
1272 | 1272 |
) |
1273 | 1273 |
booking6.cancel() |
1274 | 1274 |
booking7 = Booking.objects.create( |
... | ... | |
1279 | 1279 |
in_waiting_list=True, |
1280 | 1280 |
) |
1281 | 1281 |
booking8 = Booking.objects.create( |
1282 |
event=event, |
|
1283 |
user_external_id='user:8', |
|
1284 |
user_first_name='User', |
|
1285 |
user_last_name='Waiting and Cancelled', |
|
1286 |
in_waiting_list=True, |
|
1287 |
) |
|
1288 |
booking8.cancel() |
|
1289 |
booking9 = Booking.objects.create( |
|
1282 | 1290 |
event=event, |
1283 | 1291 |
user_external_id='user:1', |
1284 | 1292 |
user_first_name='User', |
... | ... | |
1295 | 1303 |
) |
1296 | 1304 |
Subscription.objects.create( |
1297 | 1305 |
agenda=agenda, |
1298 |
user_external_id='user:8',
|
|
1306 |
user_external_id='user:9',
|
|
1299 | 1307 |
user_first_name='Subscription', |
1300 | 1308 |
user_last_name='43', |
1301 | 1309 |
date_start=now(), |
... | ... | |
1303 | 1311 |
) |
1304 | 1312 |
Subscription.objects.create( |
1305 | 1313 |
agenda=agenda, |
1306 |
user_external_id='user:9',
|
|
1314 |
user_external_id='user:10',
|
|
1307 | 1315 |
user_first_name='Subscription', |
1308 | 1316 |
user_last_name='14', |
1309 | 1317 |
date_start=now(), |
... | ... | |
1364 | 1372 |
< resp.text.index('Waiting List (1/5)') |
1365 | 1373 |
< resp.text.index('User Waiting') |
1366 | 1374 |
) |
1367 |
assert 'User Cancelled' not in resp |
|
1375 |
assert 'User 12 Cancelled' not in resp |
|
1376 |
assert 'User Waiting and Cancelled' not in resp |
|
1368 | 1377 |
assert 'Subscription Waiting' not in resp |
1369 | 1378 |
assert 'Subscription 42' not in resp |
1370 | 1379 |
assert 'Subscription too soon' not in resp |
1371 | 1380 |
assert 'Subscription too late' not in resp |
1372 | 1381 | |
1382 |
agenda.cancelled_bookings_on_check_page = True |
|
1383 |
agenda.save() |
|
1384 |
resp = app.get('/manage/agendas/%s/events/%s/check' % (agenda.pk, event.pk)) |
|
1385 |
assert ( |
|
1386 |
resp.text.index('Bookings (6/10)') |
|
1387 |
< resp.text.index('User 01') |
|
1388 |
< resp.text.index('User 05') |
|
1389 |
< resp.text.index('User 12 Cancelled') |
|
1390 |
< resp.text.index('Subscription 14') |
|
1391 |
< resp.text.index('(Not booked)') |
|
1392 |
< resp.text.index('User 17') |
|
1393 |
< resp.text.index('User 35') |
|
1394 |
< resp.text.index('User 42') |
|
1395 |
< resp.text.index('Subscription 43') |
|
1396 |
< resp.text.index('Waiting List (1/5)') |
|
1397 |
< resp.text.index('User Waiting') |
|
1398 |
< resp.text.index('User Waiting and Cancelled') |
|
1399 |
) |
|
1400 | ||
1373 | 1401 |
agenda.booking_user_block_template = '{{ booking.user_name }} Foo Bar' |
1374 | 1402 |
agenda.save() |
1375 | 1403 |
resp = app.get('/manage/agendas/%s/events/%s/check' % (agenda.pk, event.pk)) |
... | ... | |
1404 | 1432 | |
1405 | 1433 |
# secondary booking |
1406 | 1434 |
app.post( |
1407 |
'/manage/agendas/%s/bookings/%s/presence' % (agenda.pk, booking8.pk),
|
|
1435 |
'/manage/agendas/%s/bookings/%s/presence' % (agenda.pk, booking9.pk),
|
|
1408 | 1436 |
params={'csrfmiddlewaretoken': token}, |
1409 | 1437 |
status=404, |
1410 | 1438 |
) |
1411 | 1439 |
app.post( |
1412 |
'/manage/agendas/%s/bookings/%s/absence' % (agenda.pk, booking8.pk),
|
|
1440 |
'/manage/agendas/%s/bookings/%s/absence' % (agenda.pk, booking9.pk),
|
|
1413 | 1441 |
params={'csrfmiddlewaretoken': token}, |
1414 | 1442 |
status=404, |
1415 | 1443 |
) |
... | ... | |
1442 | 1470 |
resp = app.get('/manage/agendas/%s/events/%s/' % (agenda.pk, event.pk)) |
1443 | 1471 |
assert '/manage/agendas/%s/events/%s/check' % (agenda.pk, event.pk) not in resp |
1444 | 1472 |
app.get('/manage/agendas/%s/events/%s/check' % (agenda.pk, event.pk), status=404) |
1445 |
event.cancellation_datetime = None |
|
1446 | 1473 | |
1447 | 1474 | |
1448 | 1475 |
def test_event_checked(app, admin_user): |
1449 |
- |