diff --git a/program/views.py b/program/views.py index 6c19c5327835384b5eb7ef593b42d4e8d368f142..22cb078908a11b6b696b6aca58979189373d0e4b 100644 --- a/program/views.py +++ b/program/views.py @@ -471,9 +471,19 @@ class APIScheduleViewSet(viewsets.ModelViewSet): if 'schedule' not in request.data: return Response(status=status.HTTP_400_BAD_REQUEST) + # If we're updating the default playlist id + # TODO: If nothing else than default_playlist_id, automation_id or is_repetition changed -> just save and don't do anything + new_schedule = request.data.get('schedule') + if 'default_playlist_id' in new_schedule: + schedule = get_object_or_404(Schedule, pk=pk, show=show_pk) + schedule.default_playlist_id = int(new_schedule['default_playlist_id']) + schedule.save() + + serializer = ScheduleSerializer(schedule) + return Response(serializer.data) + # First update submit -> return projected timeslots and collisions if 'solutions' not in request.data: - # TODO: If nothing else than default_playlist_id, automation_id or is_repetition changed -> just save and don't do anything return Response(Schedule.make_conflicts(request.data['schedule'], pk, show_pk)) # Otherwise try to resolve