File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -201,6 +201,13 @@ def replay(request: HttpRequest) -> HttpResponse:
201201@login_required
202202def match_replay (request : HttpRequest , match_id : int ) -> HttpResponse :
203203 match = get_object_or_404 (Match , id = match_id )
204+ if request .user not in [match .player1 .user , match .player2 .user ]:
205+ messages .error (
206+ request ,
207+ "You can only view replays of matches you participated in." ,
208+ extra_tags = "danger" ,
209+ )
210+ return redirect ("games:queue" )
204211 games = list (match .games .order_by ("created_at" ))
205212 selected_game_id = request .GET .get ("game_id" )
206213 if selected_game_id :
Original file line number Diff line number Diff line change @@ -45,7 +45,14 @@ <h1>Running Matches</h1>
4545 {{ match.player2.get_game_name }}
4646 </ td >
4747 < td > {% if match.is_ranked %}Yes{% else %}No{% endif %}</ td >
48- < td > {{ match.status }}{% if match.status == 'completed' %} < a href ="{% url 'games:match_replay' match.id %} "> (Replay)</ a > {% endif %}</ td >
48+ < td >
49+ {{ match.status }}
50+ {% if match.status == 'completed' %}
51+ {% if user == match.player1.user or user == match.player2.user %}
52+ < a href ="{% url 'games:match_replay' match.id %} "> (Replay)</ a >
53+ {% endif %}
54+ {% endif %}
55+ </ td >
4956 < td > {{ match.created_at }}</ td >
5057 </ tr >
5158 {% endfor %}
You can’t perform that action at this time.
0 commit comments