Skip to content

Commit

Permalink
In-progress Endpoint to call compilation pubsub
Browse files Browse the repository at this point in the history
  • Loading branch information
n8kim1 committed Dec 28, 2020
1 parent c4cee49 commit 80d2670
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions backend/api/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -721,6 +721,27 @@ def retrieve_file(self, request, team, league_id, pk=None):
return Response({'download_url': download_url}, status.HTTP_200_OK)


@action(methods=['patch', 'post'], detail=True)
def compilation_pubsub_call(self, request, team, league_id, pk=None):
submission = self.get_queryset().get(pk=pk)
if team != submission.team:
return Response({'message': 'Not authenticated on the right team'}, status.HTTP_401_UNAUTHORIZED)

# TODO checks for old status, before setting
# (eg a submission w status success shouldn't be tossed on the pubsub again.)
# (might make sense for any other status to be tossed on again, though)

# TODO save to a status that indicates confirmation of submission being in a bucket
submission.compilation_status = 0
submission.save()

# TODO call the pubsub here

# TODO if message successfully added to pubsub,
# change to a status that indicates being queued

return Response({'message': 'Status updated'}, status.HTTP_200_OK)

@action(methods=['patch', 'post'], detail=True)
def compilation_update(self, request, team, league_id, pk=None):
is_admin = User.objects.all().get(username=request.user).is_superuser
Expand Down

0 comments on commit 80d2670

Please sign in to comment.