Skip to content

Commit

Permalink
add TODO for #107, add league matches list in staff view and template
Browse files Browse the repository at this point in the history
  • Loading branch information
mikemaddem committed Sep 3, 2020
1 parent e29db65 commit ce1db6c
Show file tree
Hide file tree
Showing 2 changed files with 79 additions and 17 deletions.
54 changes: 54 additions & 0 deletions project-templates/staff/matches/matches.html
Expand Up @@ -115,5 +115,59 @@ <h2>Wager Matches</h2>
{% endfor %}
</table>

<h2>League Matches</h2>
<table class="table table-hover">
<tr id="header">
<thead>
<th scope="row">ID</th>
<th>Platform</th>
<th>Game</th>
<th>Away Team</th>
<th>Home Team</th>
<th>Completed</th>
<th>Size</th>
<th>Byes</th>
</thead>
</tr>
{% for match in lmatches %}
<tbody>
<tr scope="">
<td scope="row"><a href="{% url 'staff:match_detail' pk=match.id %}">#{{ match.id }}</a></td>

<td><a href="{% url 'staff:platform_detail' pk=match.platform.id %}">{{ match.platform.name }}</a>
</td>

<td><a href="{% url 'staff:game_detail' pk=match.game.id %}">{{ match.game.name }}</a></td>

<td><a href="{% url 'staff:team_detail' pk=match.awayteam.id %}">{{ match.awayteam.name }}</a></td>

<td><a href="{% url 'staff:team_detail' pk=match.hometeam.id %}">{{ match.hometeam.name }}</a></td>

{% if match.completed %}
<td>Yes</td>
{% elif not match.completed %}
<td>No</td>
{% endif %}

<td>Something</td>

{% if not match.bye_1 and not match.bye_2 %}
<td>No</td>
{% else %}
<td>Yes</td>
{% endif %}

{% if not match.completed %}
<td><a href="{% url 'staff:match_declare_winner' pk=match.id %}" class="btn btn-primary">Declare
Winner</a></td>
{% else %}
<td><a href="{% url 'staff:match_delete_winner' pk=match.id %}" class="btn btn-danger">Delete
Winner</a></td>
{% endif %}
</tr>
</tbody>
{% endfor %}
</table>

</div>
{% endblock %}
42 changes: 25 additions & 17 deletions staff/views/matches.py
Expand Up @@ -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):
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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):
Expand Down

0 comments on commit ce1db6c

Please sign in to comment.