Projet

Général

Profil

0001-api-include-full-meeting-timeslot-as-disabled-values.patch

Frédéric Péters, 09 août 2017 20:54

Télécharger (2,42 ko)

Voir les différences:

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(-)
chrono/api/views.py
168 168
        for time_slot in all_time_slots:
169 169
            if time_slot.start_datetime < now_datetime:
170 170
                continue
171
            if any((x for x in busy_time_slots if x.full and time_slot.intersects(x))):
172
                continue
171
            time_slot.full = bool(any((x for x in busy_time_slots if x.full and time_slot.intersects(x))))
173 172
            entries.append(time_slot)
174 173

  
175 174
        entries.sort(key=lambda x: x.start_datetime)
......
177 176
        response = {'data': [{'id': x.id,
178 177
                              'datetime': localtime(x.start_datetime).strftime('%Y-%m-%d %H:%M:%S'),
179 178
                              'text': unicode(x),
179
                              'disabled': bool(x.full),
180 180
                              'api': {
181 181
                                  'fillslot_url': request.build_absolute_uri(
182 182
                                      reverse('api-fillslot',
tests/test_api.py
210 210
    booking.save()
211 211

  
212 212
    resp2 = app.get('/api/agenda/meetings/%s/datetimes/' % meeting_type.id)
213
    assert len(resp2.json['data']) == 143
213
    assert len(resp2.json['data']) == 144
214 214
    assert resp.json['data'][0] == resp2.json['data'][0]
215 215
    assert resp.json['data'][1] == resp2.json['data'][1]
216
    assert resp.json['data'][3] == resp2.json['data'][2]
216
    assert resp.json['data'][2] != resp2.json['data'][2]
217
    assert resp.json['data'][2]['disabled'] is False
218
    assert resp2.json['data'][2]['disabled'] is True
219
    assert resp.json['data'][3] == resp2.json['data'][3]
217 220

  
218 221
    # test with a timeperiod overlapping current moment, it should get one
219 222
    # datetime for the current timeperiod + two from the next week.
220
-