From c61adb84e2631bc5b7674f7e9d52bef9630bf048 Mon Sep 17 00:00:00 2001 From: root Date: Wed, 27 Nov 2019 12:44:54 +0100 Subject: [PATCH] Minor tweaks to templates, permissions fix --- geogame/main/views.py | 5 ++++- geogame/templates/game_base.html | 12 +++++------- geogame/templates/main/edit_challenge_form.html | 2 +- geogame/templates/main/homepage.html | 3 ++- 4 files changed, 12 insertions(+), 10 deletions(-) diff --git a/geogame/main/views.py b/geogame/main/views.py index c145b60..0b6fdb8 100644 --- a/geogame/main/views.py +++ b/geogame/main/views.py @@ -162,11 +162,14 @@ class NewGameView(views.LoginRequiredMixin, View): ) -class RoundView(views.LoginRequiredMixin, UpdateView): +class RoundView(views.UserPassesTestMixin, UpdateView): model = GameRound form_class = GuessForm template_name = 'main/round.html' + def test_func(self, *args, **kwargs): + return self.request.user == get_object_or_404(Game, pk=self.kwargs.get('game_pk', 0)).user + def get_object(self): round_id = self.kwargs.get('round_pk', 0) return get_object_or_404(GameRound, pk=round_id) diff --git a/geogame/templates/game_base.html b/geogame/templates/game_base.html index 176f390..a670e66 100644 --- a/geogame/templates/game_base.html +++ b/geogame/templates/game_base.html @@ -11,7 +11,9 @@ Geogame - + + +