From e88e7376e817855650ef77e185ac6aed8d6c7956 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20P=C3=A9ters?= Date: Thu, 10 Aug 2017 09:25:14 +0200 Subject: [PATCH] api: optimize fillslot endpoint calculation in meetings/datetimes API (#17954) --- chrono/api/views.py | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/chrono/api/views.py b/chrono/api/views.py index daeaa3f..186d472 100644 --- a/chrono/api/views.py +++ b/chrono/api/views.py @@ -173,19 +173,21 @@ class MeetingDatetimes(GenericAPIView): entries.sort(key=lambda x: x.start_datetime) + fillslot_url = request.build_absolute_uri( + reverse('api-fillslot', + kwargs={ + 'agenda_identifier': agenda.slug, + 'event_pk': '00000', + })) + 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', - kwargs={ - 'agenda_identifier': agenda.slug, - 'event_pk': x.id, - })), - } - } for x in entries]} + 'fillslot_url': fillslot_url.replace('00000', str(x.id)), + }, + } for x in entries]} return Response(response) meeting_datetimes = MeetingDatetimes.as_view() -- 2.14.0