コード例 #1
0
ファイル: views.py プロジェクト: humblejok/gso_betsforfriends
def matchs_generate(request):
    if request.user.id!=None and request.user.is_authenticated and request.user.is_superuser:
        generate_events()
        generate_matchs()
        return HttpResponse('{"result": true, "message":"No problem"}', content_type="application/json");
    else:
        raise PermissionDenied()
コード例 #2
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()
コード例 #3
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()
コード例 #4
0
def matchs_generate(request):
    if request.user.id != None and request.user.is_authenticated and request.user.is_superuser:
        generate_events()
        generate_matchs()
        return HttpResponse('{"result": true, "message":"No problem"}',
                            content_type="application/json")
    else:
        raise PermissionDenied()
コード例 #5
0
 def handle(self, *args, **options):
     begin = dt.combine(dates.AddDay(datetime.date.today(),-7), dt.min.time())
     active_events = BettableEvent.objects.filter(end_date__gte=begin).order_by('name')
     for event in active_events:
         providers = Provider.objects.filter(event__id=event.id)
         event_meta = get_event_meta(event)
         for provider in providers:
             provider.get_all_matches_info()
         for m_type in event_meta['final_phases'][1:]:
             complete_meta_for_type(event, m_type)
     compute_event_ranking()
     compute_group_ranking()
     compute_overall_ranking()
     generate_matchs()
コード例 #6
0
ファイル: views.py プロジェクト: humblejok/gso_betsforfriends
def matchs_schedule_update(request):
    if request.user.id!=None and request.user.is_authenticated and request.user.is_superuser:
        match_id = request.POST['match_id']
        new_date = request.POST['new_date']
        new_time = request.POST['new_time']
        new_full_date = new_date + ' ' + new_time
        new_full_date = dt.strptime(new_full_date, '%Y-%m-%d %H:%M')
        match = Match.objects.get(id=match_id)
        match.when = new_full_date
        match.save()
        generate_events()
        generate_matchs()
        return HttpResponse('{"result": true, "message":"No problem"}', content_type="application/json");
    else:
        raise PermissionDenied()
コード例 #7
0
 def handle(self, *args, **options):
     begin = dt.combine(dates.AddDay(datetime.date.today(), -7),
                        dt.min.time())
     active_events = BettableEvent.objects.filter(
         end_date__gte=begin).order_by('name')
     for event in active_events:
         providers = Provider.objects.filter(event__id=event.id)
         event_meta = get_event_meta(event)
         for provider in providers:
             provider.get_all_matches_info()
         for m_type in event_meta['final_phases'][1:]:
             complete_meta_for_type(event, m_type)
     compute_event_ranking()
     compute_group_ranking()
     compute_overall_ranking()
     generate_matchs()
コード例 #8
0
def matchs_schedule_update(request):
    if request.user.id != None and request.user.is_authenticated and request.user.is_superuser:
        match_id = request.POST['match_id']
        new_date = request.POST['new_date']
        new_time = request.POST['new_time']
        new_full_date = new_date + ' ' + new_time
        new_full_date = dt.strptime(new_full_date, '%Y-%m-%d %H:%M')
        match = Match.objects.get(id=match_id)
        match.when = new_full_date
        match.save()
        generate_events()
        generate_matchs()
        return HttpResponse('{"result": true, "message":"No problem"}',
                            content_type="application/json")
    else:
        raise PermissionDenied()