コード例 #1
0
ファイル: views.py プロジェクト: humblejok/gso_betsforfriends
def matchs_save(request):
    if request.user.id!=None and request.user.is_authenticated and request.user.is_superuser:
        message = "Aucun probleme."
        all_matchs = json.loads(request.POST['all_matchs'])
        event_id = request.POST['event_id']
        for match in all_matchs:
            LOGGER.info("Working on match " + str(match))
            web_match = all_matchs[match]
            py_match = Match.objects.get(id=match)
            if py_match.result==None:
                score = Score()
            else:
                score = Score.objects.get(id=py_match.result.id)
            score.first = web_match[u'score'][u'first']
            score.second = web_match[u'score'][u'second']
            score.name = "Official score " + py_match.name
            score.save()
                
            py_match.result = score
            py_match.save()
        generate_matchs(all_matchs.keys())
        event = BettableEvent.objects.get(id=event_id)
        generates_per_participant_result(event)
        # TODO: Change
        if event.sport.identifier=='SPORT_FOOTBALL':
            compute_fifa_wc_pools(event)
            compute_fifa_wc_8th(event)
        event_meta = get_event_meta(event)
        for m_type in event_meta['final_phases'][1:]:
            complete_meta_for_type(event, m_type)
        return HttpResponse('{"result": true, "message":"' + message + '"}', content_type="application/json");
    else:
        raise PermissionDenied()
コード例 #2
0
def matchs_save(request):
    if request.user.id != None and request.user.is_authenticated and request.user.is_superuser:
        message = "Aucun probleme."
        all_matchs = json.loads(request.POST['all_matchs'])
        event_id = request.POST['event_id']
        for match in all_matchs:
            LOGGER.info("Working on match " + str(match))
            web_match = all_matchs[match]
            py_match = Match.objects.get(id=match)
            if py_match.result == None:
                score = Score()
            else:
                score = Score.objects.get(id=py_match.result.id)
            score.first = web_match[u'score'][u'first']
            score.second = web_match[u'score'][u'second']
            score.name = "Official score " + py_match.name
            score.save()

            py_match.result = score
            py_match.save()
        generate_matchs(all_matchs.keys())
        event = BettableEvent.objects.get(id=event_id)
        generates_per_participant_result(event)
        # TODO: Change
        if event.sport.identifier == 'SPORT_FOOTBALL':
            compute_fifa_wc_pools(event)
            compute_fifa_wc_8th(event)
        event_meta = get_event_meta(event)
        for m_type in event_meta['final_phases'][1:]:
            complete_meta_for_type(event, m_type)
        return HttpResponse('{"result": true, "message":"' + message + '"}',
                            content_type="application/json")
    else:
        raise PermissionDenied()