0001-api-add-more-infos-on-places-for-an-event-agenda-404.patch
chrono/api/views.py | ||
---|---|---|
135 | 135 | |
136 | 136 | |
137 | 137 |
def get_event_places(event): |
138 |
available = event.places - event.booked_places |
|
138 | 139 |
places = { |
139 | 140 |
'total': event.places, |
140 | 141 |
'reserved': event.booked_places, |
141 |
'available': event.places - event.booked_places, |
|
142 |
'available': available, |
|
143 |
'full': event.full, |
|
144 |
'has_waiting_list': False, |
|
142 | 145 |
} |
143 | 146 |
if event.waiting_list_places: |
147 |
places['has_waiting_list'] = True |
|
144 | 148 |
places['waiting_list_total'] = event.waiting_list_places |
145 | 149 |
places['waiting_list_reserved'] = event.waiting_list |
146 | 150 |
places['waiting_list_available'] = event.waiting_list_places - event.waiting_list |
151 |
places['waiting_list_activated'] = event.waiting_list > 0 or available == 0 |
|
152 |
# 'waiting_list_activated' means next booking will go into the waiting list |
|
153 | ||
147 | 154 |
return places |
148 | 155 | |
149 | 156 |
tests/test_api.py | ||
---|---|---|
945 | 945 |
assert resp.json['places']['waiting_list_total'] == 5 |
946 | 946 |
assert resp.json['places']['waiting_list_available'] == 3 |
947 | 947 |
assert resp.json['places']['waiting_list_reserved'] == 2 |
948 |
assert resp.json['places']['waiting_list_activated'] is True |
|
948 | 949 | |
949 | 950 |
# not for mettings agenda |
950 | 951 |
meeting_type = MeetingType.objects.get(agenda=meetings_agenda) |
... | ... | |
992 | 993 |
assert resp.json['places']['waiting_list_total'] == 2 |
993 | 994 |
assert resp.json['places']['waiting_list_available'] == 2 |
994 | 995 |
assert resp.json['places']['waiting_list_reserved'] == 0 |
996 |
assert resp.json['places']['waiting_list_activated'] is False |
|
995 | 997 | |
996 | 998 |
# add another booking |
997 | 999 |
resp = app.post_json( |
... | ... | |
1004 | 1006 |
assert resp.json['places']['waiting_list_total'] == 2 |
1005 | 1007 |
assert resp.json['places']['waiting_list_available'] == 2 |
1006 | 1008 |
assert resp.json['places']['waiting_list_reserved'] == 0 |
1009 |
assert resp.json['places']['waiting_list_activated'] is False |
|
1007 | 1010 | |
1008 | 1011 |
# add a booking, but in waiting list |
1009 | 1012 |
resp = app.post_json( |
... | ... | |
1016 | 1019 |
assert resp.json['places']['waiting_list_total'] == 2 |
1017 | 1020 |
assert resp.json['places']['waiting_list_available'] == 1 |
1018 | 1021 |
assert resp.json['places']['waiting_list_reserved'] == 1 |
1022 |
assert resp.json['places']['waiting_list_activated'] is True |
|
1019 | 1023 | |
1020 | 1024 |
# add a booking => booked in waiting list |
1021 | 1025 |
resp = app.post_json('/api/agenda/%s/fillslot/%s/' % (agenda.pk, event.pk)) |
... | ... | |
1026 | 1030 |
assert resp.json['places']['waiting_list_total'] == 2 |
1027 | 1031 |
assert resp.json['places']['waiting_list_available'] == 0 |
1028 | 1032 |
assert resp.json['places']['waiting_list_reserved'] == 2 |
1033 |
assert resp.json['places']['waiting_list_activated'] is True |
|
1029 | 1034 | |
1030 | 1035 |
# waiting list is full |
1031 | 1036 |
resp = app.post_json( |
1032 |
- |