0001-api-return-events-details-if-multiple-booking-38330.patch
chrono/api/views.py | ||
---|---|---|
576 | 576 |
if agenda.kind == 'events' and not multiple_booking: |
577 | 577 |
event = events[0] |
578 | 578 |
response['places'] = get_event_places(event) |
579 |
if agenda.kind == 'events' and multiple_booking: |
|
580 |
response['events'] = [ |
|
581 |
{ |
|
582 |
'slug': x.slug, |
|
583 |
'text': force_text(x), |
|
584 |
'datetime': format_response_datetime(x.start_datetime), |
|
585 |
'description': x.description |
|
586 |
} for x in events |
|
587 |
] |
|
579 | 588 | |
580 | 589 |
return Response(response) |
581 | 590 |
tests/test_api.py | ||
---|---|---|
6 | 6 |
from django.db import connection |
7 | 7 |
from django.test import override_settings |
8 | 8 |
from django.test.utils import CaptureQueriesContext |
9 |
from django.utils.encoding import force_text |
|
9 | 10 |
from django.utils.six.moves.urllib import parse as urlparse |
10 | 11 |
from django.utils.timezone import now, make_aware, localtime |
11 | 12 | |
... | ... | |
1233 | 1234 |
assert 'accept_url' not in resp.json['api'] |
1234 | 1235 |
assert 'cancel_url' in resp.json['api'] |
1235 | 1236 |
assert 'ics_url' in resp.json['api'] |
1237 |
resp_events = resp.json['events'] |
|
1238 |
assert len(resp_events) == len(events) |
|
1239 |
for (e, resp_e) in zip(events, resp_events): |
|
1240 |
assert e.slug == resp_e['slug'] |
|
1241 |
assert e.description == resp_e['description'] |
|
1242 |
assert force_text(e) == resp_e['text'] |
|
1243 |
assert localtime(e.start_datetime).strftime('%Y-%m-%d %H:%M:%S') == resp_e['datetime'] |
|
1236 | 1244 |
for event in events: |
1237 | 1245 |
assert Event.objects.get(id=event.id).booked_places == 3 |
1238 | 1246 | |
1239 |
- |