def post(self, request, *args, **kwargs):
     # Get match, team, end and score
     try:
         match = SchenkelMatch.objects.get(pk=request.POST['match_pk'])
         team = Team.objects.get(pk=request.POST['team_pk'])
         end = End.objects.get(pk=request.POST['end_pk'])
         score = int(request.POST['score'])
     except(KeyError, ValueError, SchenkelMatch.DoesNotExist, Team.DoesNotExist, End.DoesNotExist):
         return render_json_response_500()
     # Check if match not finished
     if match.finished:
         return render_json_response_500(
             msg=_(u'Match on sheet %s is already finished.' % match.sheet.name))
     # Create the result
     try:
         SchenkelResult.objects.create(match=match,
                                       team=team,
                                       end=end,
                                       scoring=score)
     except Exception as e:
         return render_json_response_500(msg=e)
     # Check if match is now finished
     if end.order == 8:
         match.finished = True
         match.save()
         all_matches_finished = match.group.matches_are_finished()
     else:
         all_matches_finished = False
     # Return code response and msg for user
     return render_json_response(
         match_finished=match.finished,
         all_matches_finished=all_matches_finished,
         msg=_(u'<strong>Sheet %s</strong> : <strong>%s</strong> scored <strong>%s</strong> '
               u'in <strong>end %s</strong>.') % (match.sheet.name, team.name, score, end.order))
 def post(self, request, *args, **kwargs):
     try:
         match = SchenkelMatch.objects.get(pk=request.POST['match_pk'])
     except SchenkelMatch.DoesNotExist:
         return render_json_response_500()
     if not match.finished:
         match.finished = True
         match.save()
     return render_json_response(
         match_finished=match.finished,
         all_matches_finished = match.group.matches_are_finished(),
         msg=_(u'<strong>Sheet %s</strong> : Match is finished.' % match.sheet.name))
Esempio n. 3
0
 def post(self, request, *args, **kwargs):
     try:
         match = SchenkelMatch.objects.get(pk=request.POST['match_pk'])
     except SchenkelMatch.DoesNotExist:
         return render_json_response_500()
     if not match.finished:
         match.finished = True
         match.save()
     return render_json_response(
         match_finished=match.finished,
         all_matches_finished=match.group.matches_are_finished(),
         msg=_(u'<strong>Sheet %s</strong> : Match is finished.' %
               match.sheet.name))
Esempio n. 4
0
 def post(self, request, *args, **kwargs):
     # Get match, team, end and score
     try:
         match = SchenkelMatch.objects.get(pk=request.POST['match_pk'])
         team = Team.objects.get(pk=request.POST['team_pk'])
         end = End.objects.get(pk=request.POST['end_pk'])
         score = int(request.POST['score'])
     except (KeyError, ValueError, SchenkelMatch.DoesNotExist,
             Team.DoesNotExist, End.DoesNotExist):
         return render_json_response_500()
     # Check if match not finished
     if match.finished:
         return render_json_response_500(
             msg=_(u'Match on sheet %s is already finished.' %
                   match.sheet.name))
     # Create the result
     try:
         SchenkelResult.objects.create(match=match,
                                       team=team,
                                       end=end,
                                       scoring=score)
     except Exception as e:
         return render_json_response_500(msg=e)
     # Check if match is now finished
     if end.order == 8:
         match.finished = True
         match.save()
         all_matches_finished = match.group.matches_are_finished()
     else:
         all_matches_finished = False
     # Return code response and msg for user
     return render_json_response(
         match_finished=match.finished,
         all_matches_finished=all_matches_finished,
         msg=
         _(u'<strong>Sheet %s</strong> : <strong>%s</strong> scored <strong>%s</strong> '
           u'in <strong>end %s</strong>.') %
         (match.sheet.name, team.name, score, end.order))