From 28e94893c56ac91052be113d0e21469b1d7b1136 Mon Sep 17 00:00:00 2001 From: root Date: Sat, 31 Aug 2019 17:54:46 +0200 Subject: [PATCH] smoll fix to new game logic --- geogame/main/views.py | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/geogame/main/views.py b/geogame/main/views.py index e338d06..14f4cf1 100644 --- a/geogame/main/views.py +++ b/geogame/main/views.py @@ -39,16 +39,19 @@ class HomePageView(TemplateView): if user.is_authenticated: if user.api_key: context['has_api_key'] = True - game = Game.objects.filter(user=user, active=True) - if game and game.exists(): - game = game.first() - if not GameRound.objects.get(game=game, order=4).guess_lat: - context['existing_game'] = game - rounds = GameRound.objects.filter(game=game).order_by('order') - for round in rounds: - if not round.guess_lat or not round.guess_lng: - context['existing_round'] = round - break + try: + game = Game.objects.filter(user=user, active=True) + if game and game.exists(): + game = game.first() + if not GameRound.objects.get(game=game, order=4).guess_lat: + context['existing_game'] = game + rounds = GameRound.objects.filter(game=game).order_by('order') + for round in rounds: + if not round.guess_lat or not round.guess_lng: + context['existing_round'] = round + break + except: + pass else: context['has_api_key'] = False return context @@ -79,7 +82,7 @@ class ContributeView(views.LoginRequiredMixin, CreateView): self.object = form.save(commit=False) self.object.user = self.request.user self.object.save() - messages.success(self.request, "Thank you so much for helping the site, you coordinates have been added.") + messages.success(self.request, "Your coordinates have been added.") return redirect(self.get_success_url())