api: return 400 when no events found (#38333)
This commit is contained in:
parent
c420dde65d
commit
559452990c
|
@ -587,6 +587,16 @@ class Fillslots(APIView):
|
|||
except ValueError:
|
||||
events = Event.objects.filter(slug__in=slots).order_by('start_datetime')
|
||||
|
||||
if not events.count():
|
||||
return Response(
|
||||
{
|
||||
'err': 1,
|
||||
'err_class': 'unknown event identifiers or slugs',
|
||||
'err_desc': _('unknown event identifiers or slugs'),
|
||||
},
|
||||
status=status.HTTP_400_BAD_REQUEST,
|
||||
)
|
||||
|
||||
# search free places. Switch to waiting list if necessary.
|
||||
in_waiting_list = False
|
||||
for event in events:
|
||||
|
|
|
@ -684,11 +684,9 @@ def test_booking_api_fillslots(app, some_data, user):
|
|||
# invalid slots format
|
||||
resp = app.post_json('/api/agenda/%s/fillslots/' % agenda.id, params={'slots': 'foobar'}, status=400)
|
||||
assert resp.json['err'] == 1
|
||||
assert resp.json['reason'] == 'invalid payload' # legacy
|
||||
assert resp.json['err_class'] == 'invalid payload'
|
||||
assert resp.json['err_desc'] == 'invalid payload'
|
||||
assert len(resp.json['errors']) == 1
|
||||
assert 'slots' in resp.json['errors']
|
||||
assert resp.json['reason'] == 'unknown event identifiers or slugs' # legacy
|
||||
assert resp.json['err_class'] == 'unknown event identifiers or slugs'
|
||||
assert resp.json['err_desc'] == 'unknown event identifiers or slugs'
|
||||
|
||||
# unknown agendas
|
||||
resp = app.post('/api/agenda/foobar/fillslots/', status=404)
|
||||
|
|
Loading…
Reference in New Issue