Skip to content
Snippets Groups Projects

bugfix: adding missing access control allow origin header

Merged Benoit Alessandroni requested to merge bugfix/adding-missing-response-header into master
1 file
+ 3
1
Compare changes
  • Side-by-side
  • Inline
+ 3
1
@@ -16,12 +16,14 @@ class CanVoteOnPollViewSet(APIView):
@@ -16,12 +16,14 @@ class CanVoteOnPollViewSet(APIView):
def get(self, request, pk):
def get(self, request, pk):
'''returns True if the user can vote, or False if they have already voted'''
'''returns True if the user can vote, or False if they have already voted'''
 
headers = {"Access-Control-Allow-Origin" : request.META.get('HTTP_ORIGIN')}
 
try:
try:
poll = Poll.objects.get(pk=pk)
poll = Poll.objects.get(pk=pk)
can_vote = True
can_vote = True
if Vote.objects.filter(relatedPoll=poll, user=request.user).exists():
if Vote.objects.filter(relatedPoll=poll, user=request.user).exists():
can_vote = False
can_vote = False
return Response(can_vote, status=status.HTTP_200_OK)
return Response(can_vote, status=status.HTTP_200_OK, headers=headers)
except Poll.DoesNotExist:
except Poll.DoesNotExist:
return Response(data={'error': {'poll': ['Could not find poll with this ID!']}},
return Response(data={'error': {'poll': ['Could not find poll with this ID!']}},
Loading