From 88204b19afa9bd991ae3b394c6d4f647b394984f Mon Sep 17 00:00:00 2001 From: root Date: Tue, 26 Nov 2019 11:34:39 +0100 Subject: [PATCH] Minor fixes --- geogame/main/views.py | 8 +++++++- geogame/templates/main/game_recap.html | 2 +- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/geogame/main/views.py b/geogame/main/views.py index dfb8f3a..b05b6ec 100644 --- a/geogame/main/views.py +++ b/geogame/main/views.py @@ -55,10 +55,15 @@ class ProfilePageView(views.LoginRequiredMixin, TemplateView): return context -class UpdateAPIView(views.LoginRequiredMixin, UpdateView): +class UpdateAPIView(views.UserPassesTestMixin, UpdateView): model = User form_class = APIForm template_name = 'main/api_form.html' + raise_exception = True + + def test_func(self, user): + user = get_object_or_404(User, pk=self.kwargs.get('pk', 0)) + return user == self.request.user def get_success_url(self): return reverse_lazy('profile') @@ -305,6 +310,7 @@ class GameRecapView(views.UserPassesTestMixin, TemplateView): context = super(GameRecapView, self).get_context_data(**kwargs) game_id = self.kwargs.get('game_pk', 0) game = get_object_or_404(Game, pk=game_id) + self.request.user.deactive_games() coord_results = [] distance_total = 0 diff --git a/geogame/templates/main/game_recap.html b/geogame/templates/main/game_recap.html index 9ae2c31..eae11c6 100644 --- a/geogame/templates/main/game_recap.html +++ b/geogame/templates/main/game_recap.html @@ -19,7 +19,7 @@
- New Game + Homepage