diff --git a/tipp/views.py b/tipp/views.py index 6f2cde6..54e1040 100644 --- a/tipp/views.py +++ b/tipp/views.py @@ -56,7 +56,7 @@ def home(request): return redirect("matchday", ls = ls, season = season, - matchday=str(md['groupOrderID']).zfill(2) + matchday=str(md).zfill(2) ) @login_required @@ -165,7 +165,7 @@ def getSeason(request, ls, season): ) m.save() - return redirect("matchday", ls=ls, season=season, matchday=md['groupOrderID']) + return redirect("matchday", ls=ls, season=season, matchday=md) @login_required @@ -199,32 +199,29 @@ def update(request, ls, season, cur_md): m = Match(matchID=unicode(match['matchID']), - matchDateTime=datetime.strptime(unicode(match['matchDateTime']), '%Y-%m-%d %H:%M:%S'), - group=int(match['groupID']), - matchday=int(match['groupOrderID']), - matchday_name = match['groupName'], - idTeam1=Team.objects.get(teamID=int(match['idTeam1'])), - idTeam2=Team.objects.get(teamID=int(match['idTeam2'])), pointsTeam1=pointsTeam1, pointsTeam2=pointsTeam2, finished=bool(match['matchIsFinished']), - season=match['leagueSaison'], - leagueShortcut=match['leagueShortcut'] ) - m.save() + m.save(update_fields=['pointsTeam1', 'pointsTeam2', 'finished']) pointsTeam1=-1 pointsTeam2=-1 - """ evaluate scores """ + # evaluate scores scores = Score.objects.get(client=Mandant.objects.get(name='huse')) - finished_matches=Match.objects.filter(finished=True) + finished_matches=Match.objects.filter( + finished=True, + leagueShortcut=ls, + season=season, + matchday = cur_md + ) for match in finished_matches: tipps = Tipp.objects.filter(matchID=match.matchID) for tipp in tipps: score = 0 goals_total = match.pointsTeam1 + match.pointsTeam2 - """ Tipp is acurate """ + # Tipp is acurate if (tipp.pointsTeam1 == match.pointsTeam1 and tipp.pointsTeam2 == match.pointsTeam2): if goals_total >= 5: score = scores.exact_high @@ -235,7 +232,7 @@ def update(request, ls, season, cur_md): tipp.save() continue - """ who won? """ + # who won? winnerReal = None if match.pointsTeam1 > match.pointsTeam2: winnerReal = 1 @@ -430,7 +427,7 @@ def charts(request, ls, season, pos='default', template_name='charts.html'): debug = '' if pos == 'default': - if get_current_md(ls, season) < 18: + if get_current_md(ls) < 18: pos = 'hin' matches = Match.objects.filter(leagueShortcut=ls, season=season, matchday__lte=17) else: @@ -554,7 +551,7 @@ def get_current_md(ls): except: cur_md = {'groupName': u"1. Spieltag", 'groupOrderID': 1} - return(cur_md) + return(cur_md['groupOrderID']) def get_current_ls(): return("em2016")