0001-rename.patch
chrono/api/urls.py | ||
---|---|---|
34 | 34 |
), |
35 | 35 |
url(r'^agenda/(?P<agenda_identifier>[\w-]+)/fillslots/$', views.fillslots, name='api-agenda-fillslots'), |
36 | 36 |
url( |
37 |
r'^agenda/(?P<agenda_identifier>[\w-]+)/event_fillslots/$',
|
|
38 |
views.event_fillslots, |
|
39 |
name='api-agenda-event-fillslots', |
|
37 |
r'^agenda/(?P<agenda_identifier>[\w-]+)/events/fillslots/$',
|
|
38 |
views.events_fillslots,
|
|
39 |
name='api-agenda-events-fillslots',
|
|
40 | 40 |
), |
41 | 41 |
url( |
42 | 42 |
r'^agenda/(?P<agenda_identifier>[\w-]+)/recurring_fillslots/$', |
chrono/api/views.py | ||
---|---|---|
1163 | 1163 |
return attrs |
1164 | 1164 | |
1165 | 1165 | |
1166 |
class EventSlotsSerializer(SlotsSerializer): |
|
1166 |
class EventsSlotsSerializer(SlotsSerializer):
|
|
1167 | 1167 |
def validate(self, attrs): |
1168 | 1168 |
super().validate(attrs) |
1169 | 1169 |
if not attrs.get('user_external_id'): |
... | ... | |
1551 | 1551 | |
1552 | 1552 |
class RecurringFillslots(APIView): |
1553 | 1553 |
permission_classes = (permissions.IsAuthenticated,) |
1554 |
serializer_class = EventSlotsSerializer |
|
1554 |
serializer_class = EventsSlotsSerializer
|
|
1555 | 1555 | |
1556 | 1556 |
def post(self, request, agenda_identifier): |
1557 | 1557 |
if not settings.ENABLE_RECURRING_EVENT_BOOKING: |
... | ... | |
1640 | 1640 |
recurring_fillslots = RecurringFillslots.as_view() |
1641 | 1641 | |
1642 | 1642 | |
1643 |
class EventFillslots(APIView): |
|
1643 |
class EventsFillslots(APIView):
|
|
1644 | 1644 |
permission_classes = (permissions.IsAuthenticated,) |
1645 |
serializer_class = EventSlotsSerializer |
|
1645 |
serializer_class = EventsSlotsSerializer
|
|
1646 | 1646 | |
1647 | 1647 |
def post(self, request, agenda_identifier): |
1648 | 1648 |
agenda = get_object_or_404(Agenda, slug=agenda_identifier, kind='events') |
... | ... | |
1692 | 1692 |
return Response(response) |
1693 | 1693 | |
1694 | 1694 | |
1695 |
event_fillslots = EventFillslots.as_view()
|
|
1695 |
events_fillslots = EventsFillslots.as_view()
|
|
1696 | 1696 | |
1697 | 1697 | |
1698 | 1698 |
class BookingSerializer(serializers.ModelSerializer): |
tests/api/test_fillslot.py | ||
---|---|---|
2226 | 2226 |
assert events.filter(waiting_list_count=2).count() == 5 |
2227 | 2227 | |
2228 | 2228 | |
2229 |
def test_api_event_fillslots(app, user, freezer): |
|
2229 |
def test_api_events_fillslots(app, user, freezer):
|
|
2230 | 2230 |
freezer.move_to('2021-09-06 12:00') |
2231 | 2231 |
agenda = Agenda.objects.create(label='Foo bar', kind='events') |
2232 | 2232 |
event = Event.objects.create( |
... | ... | |
2241 | 2241 |
) |
2242 | 2242 | |
2243 | 2243 |
app.authorization = ('Basic', ('john.doe', 'password')) |
2244 |
fillslots_url = '/api/agenda/%s/event_fillslots/' % agenda.slug
|
|
2244 |
fillslots_url = '/api/agenda/%s/events/fillslots/' % agenda.slug
|
|
2245 | 2245 |
params = {'user_external_id': 'user_id', 'slots': 'event,event-2'} |
2246 | 2246 |
resp = app.post_json(fillslots_url, params=params) |
2247 | 2247 |
assert resp.json['booking_count'] == 2 |
2248 |
- |