Beispiel #1
0
 def submit(self, request):
     game = Game.getByID(self.cleaned_data['game_id'])
     if not game.current_round_id:
         raise NoCurrentRound()
     
     if not GamePermissions.has_object_permission(request, game):
         raise PermissionDenied()
     
     nominations = Nomination.filterByRound(game.current_round_id)
     return NominationSerializer(nominations, many=True).data
Beispiel #2
0
 def submit(self, request):
     game = Game.getByID(self.cleaned_data['game_id'])
     if not game.current_round_id:
         raise NoCurrentRound()
     
     if not GamePermissions.has_object_permission(request, game):
         raise PermissionDenied()
     
     nominations = Nomination.filterByRound(game.current_round_id)
     users = set([str(n.nominator_id) for n in nominations])
     if request.user.pk in users:
         raise AlreadyNominated()
     
     now = datetime.datetime.now()
     try:
         NominationCard.getByID(self.cleaned_data['nomination_card_id'])
     except CassaNotFoundException:
         raise InvalidNominationCard()
     
     nomination = Nomination(round_id=game.current_round_id, nominator_id=request.user.pk,
             nomination_card_id=self.cleaned_data['nomination_card_id'], date_created=now, last_modified=now)
     nomination.save()
     
     return NominationSerializer(nomination).data