From ce1db6c214c24cb1b65ab60e32c06f7e79417d1a Mon Sep 17 00:00:00 2001 From: Michael Madden Date: Thu, 3 Sep 2020 18:01:13 -0400 Subject: [PATCH] add TODO for #107, add league matches list in staff view and template --- project-templates/staff/matches/matches.html | 54 ++++++++++++++++++++ staff/views/matches.py | 42 +++++++++------ 2 files changed, 79 insertions(+), 17 deletions(-) diff --git a/project-templates/staff/matches/matches.html b/project-templates/staff/matches/matches.html index d2e2403ac..d5d869bac 100644 --- a/project-templates/staff/matches/matches.html +++ b/project-templates/staff/matches/matches.html @@ -115,5 +115,59 @@

Wager Matches

{% endfor %} +

League Matches

+ + + + + + + + + + + + + + {% for match in lmatches %} + + + + + + + + + + + + + {% if match.completed %} + + {% elif not match.completed %} + + {% endif %} + + + + {% if not match.bye_1 and not match.bye_2 %} + + {% else %} + + {% endif %} + + {% if not match.completed %} + + {% else %} + + {% endif %} + + + {% endfor %} +
IDPlatformGameAway TeamHome TeamCompletedSizeByes
#{{ match.id }}{{ match.platform.name }} + {{ match.game.name }}{{ match.awayteam.name }}{{ match.hometeam.name }}YesNoSomethingNoYesDeclare + WinnerDelete + Winner
+ {% endblock %} \ No newline at end of file diff --git a/staff/views/matches.py b/staff/views/matches.py index e1e63880c..117166bb6 100644 --- a/staff/views/matches.py +++ b/staff/views/matches.py @@ -21,7 +21,8 @@ def matches_index(request): # matches_list = Match.objects.all().order_by('-id') tmatches = Match.objects.filter(type__isnull=True) wmatches = Match.objects.filter(type='w') - return render(request, 'staff/matches/matches.html', {'tmatches': tmatches, 'wmatches': wmatches}) + lmatches = Match.objects.filter(type="leagues") + return render(request, 'staff/matches/matches.html', {'tmatches': tmatches, 'wmatches': wmatches, 'lmatches': lmatches}) def disputed_matches(request): @@ -93,6 +94,9 @@ def post(self, request, pk): return render(request, 'staff/permissiondenied.html') else: matchobj = Match.objects.get(pk=pk) + if matchobj.type == "league": + # TODO: 107 + pass if not matchobj.bye_2 and not matchobj.bye_1: form = DeclareMatchWinnerPost(request.POST, instance=matchobj) instance = form.instance @@ -139,23 +143,27 @@ def match_delete_winner(request, pk): return render(request, 'staff/permissiondenied.html') else: match = Match.objects.get(pk=pk) - if not match.bye_1 and not match.bye_2: - match.winner = None - match.completed = False - match.reported = False - match.team1reported = False - match.team2reported = False - match.team1reportedwinner = None - match.team2reportedwinner = None - match.disputed = False - match.save() - for i in MatchReport.objects.filter(match_id=pk): - i.delete() - messages.success(request, "Winner reset") - return redirect('staff:matches_index') + if match.type == "league": + # TODO: #107 + pass else: - messages.error(request, 'Bye match, cannot change winner') - return redirect('staff:matches_index') + if not match.bye_1 and not match.bye_2: + match.winner = None + match.completed = False + match.reported = False + match.team1reported = False + match.team2reported = False + match.team1reportedwinner = None + match.team2reportedwinner = None + match.disputed = False + match.save() + for i in MatchReport.objects.filter(match_id=pk): + i.delete() + messages.success(request, "Winner reset") + return redirect('staff:matches_index') + else: + messages.error(request, 'Bye match, cannot change winner') + return redirect('staff:matches_index') def dispute_detail(request, pk):