From 87de8bd95b114ef7b93c7fe7272fcd031e7767b2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20P=C3=A9ters?= Date: Wed, 9 Aug 2017 20:53:45 +0200 Subject: [PATCH] api: include full meeting timeslot as disabled values (#17953) --- chrono/api/views.py | 4 ++-- tests/test_api.py | 7 +++++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/chrono/api/views.py b/chrono/api/views.py index 90980fb..daeaa3f 100644 --- a/chrono/api/views.py +++ b/chrono/api/views.py @@ -168,8 +168,7 @@ class MeetingDatetimes(GenericAPIView): for time_slot in all_time_slots: if time_slot.start_datetime < now_datetime: continue - if any((x for x in busy_time_slots if x.full and time_slot.intersects(x))): - continue + time_slot.full = bool(any((x for x in busy_time_slots if x.full and time_slot.intersects(x)))) entries.append(time_slot) entries.sort(key=lambda x: x.start_datetime) @@ -177,6 +176,7 @@ class MeetingDatetimes(GenericAPIView): response = {'data': [{'id': x.id, 'datetime': localtime(x.start_datetime).strftime('%Y-%m-%d %H:%M:%S'), 'text': unicode(x), + 'disabled': bool(x.full), 'api': { 'fillslot_url': request.build_absolute_uri( reverse('api-fillslot', diff --git a/tests/test_api.py b/tests/test_api.py index edbe04f..a8bfffc 100644 --- a/tests/test_api.py +++ b/tests/test_api.py @@ -210,10 +210,13 @@ def test_datetimes_api_meetings_agenda(app, meetings_agenda): booking.save() resp2 = app.get('/api/agenda/meetings/%s/datetimes/' % meeting_type.id) - assert len(resp2.json['data']) == 143 + assert len(resp2.json['data']) == 144 assert resp.json['data'][0] == resp2.json['data'][0] assert resp.json['data'][1] == resp2.json['data'][1] - assert resp.json['data'][3] == resp2.json['data'][2] + assert resp.json['data'][2] != resp2.json['data'][2] + assert resp.json['data'][2]['disabled'] is False + assert resp2.json['data'][2]['disabled'] is True + assert resp.json['data'][3] == resp2.json['data'][3] # test with a timeperiod overlapping current moment, it should get one # datetime for the current timeperiod + two from the next week. -- 2.14.0