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 | ||
---|---|---|
952 | 952 |
assert resp.json['places']['waiting_list_total'] == 5 |
953 | 953 |
assert resp.json['places']['waiting_list_available'] == 3 |
954 | 954 |
assert resp.json['places']['waiting_list_reserved'] == 2 |
955 |
assert resp.json['places']['waiting_list_activated'] is True |
|
955 | 956 | |
956 | 957 |
# not for mettings agenda |
957 | 958 |
meeting_type = MeetingType.objects.get(agenda=meetings_agenda) |
... | ... | |
999 | 1000 |
assert resp.json['places']['waiting_list_total'] == 2 |
1000 | 1001 |
assert resp.json['places']['waiting_list_available'] == 2 |
1001 | 1002 |
assert resp.json['places']['waiting_list_reserved'] == 0 |
1003 |
assert resp.json['places']['waiting_list_activated'] is False |
|
1002 | 1004 | |
1003 | 1005 |
# add another booking |
1004 | 1006 |
resp = app.post_json( |
... | ... | |
1011 | 1013 |
assert resp.json['places']['waiting_list_total'] == 2 |
1012 | 1014 |
assert resp.json['places']['waiting_list_available'] == 2 |
1013 | 1015 |
assert resp.json['places']['waiting_list_reserved'] == 0 |
1016 |
assert resp.json['places']['waiting_list_activated'] is False |
|
1014 | 1017 | |
1015 | 1018 |
# add a booking, but in waiting list |
1016 | 1019 |
resp = app.post_json( |
... | ... | |
1023 | 1026 |
assert resp.json['places']['waiting_list_total'] == 2 |
1024 | 1027 |
assert resp.json['places']['waiting_list_available'] == 1 |
1025 | 1028 |
assert resp.json['places']['waiting_list_reserved'] == 1 |
1029 |
assert resp.json['places']['waiting_list_activated'] is True |
|
1026 | 1030 | |
1027 | 1031 |
# add a booking => booked in waiting list |
1028 | 1032 |
resp = app.post_json('/api/agenda/%s/fillslot/%s/' % (agenda.pk, event.pk)) |
... | ... | |
1033 | 1037 |
assert resp.json['places']['waiting_list_total'] == 2 |
1034 | 1038 |
assert resp.json['places']['waiting_list_available'] == 0 |
1035 | 1039 |
assert resp.json['places']['waiting_list_reserved'] == 2 |
1040 |
assert resp.json['places']['waiting_list_activated'] is True |
|
1036 | 1041 | |
1037 | 1042 |
# waiting list is full |
1038 | 1043 |
resp = app.post_json( |
1039 |
- |