Projet

Général

Profil

0001-api-return-events-details-if-multiple-booking-38330.patch

Emmanuel Cazenave, 20 décembre 2019 10:43

Télécharger (1,88 ko)

Voir les différences:

Subject: [PATCH] api: return events details if multiple booking (#38330)

 chrono/api/views.py | 10 ++++++++++
 tests/test_api.py   |  7 +++++++
 2 files changed, 17 insertions(+)
chrono/api/views.py
648 648
        if agenda.kind == 'events' and not multiple_booking:
649 649
            event = events[0]
650 650
            response['places'] = get_event_places(event)
651
        if agenda.kind == 'events' and multiple_booking:
652
            response['events'] = [
653
                {
654
                    'slug': x.slug,
655
                    'text': str(x),
656
                    'datetime': format_response_datetime(x.start_datetime),
657
                    'description': x.description,
658
                }
659
                for x in events
660
            ]
651 661

  
652 662
        return Response(response)
653 663

  
tests/test_api.py
1373 1373
    assert 'accept_url' not in resp.json['api']
1374 1374
    assert 'cancel_url' in resp.json['api']
1375 1375
    assert 'ics_url' in resp.json['api']
1376
    resp_events = resp.json['events']
1377
    assert len(resp_events) == len(events)
1378
    for (e, resp_e) in zip(events, resp_events):
1379
        assert e.slug == resp_e['slug']
1380
        assert e.description == resp_e['description']
1381
        assert str(e) == resp_e['text']
1382
        assert localtime(e.start_datetime).strftime('%Y-%m-%d %H:%M:%S') == resp_e['datetime']
1376 1383
    for event in events:
1377 1384
        assert Event.objects.get(id=event.id).booked_places == 3
1378 1385

  
1379
-