smoll fix to new game logic

This commit is contained in:
root 2019-08-31 17:54:46 +02:00
parent eebd6a5ed6
commit 28e94893c5

View File

@ -39,6 +39,7 @@ class HomePageView(TemplateView):
if user.is_authenticated: if user.is_authenticated:
if user.api_key: if user.api_key:
context['has_api_key'] = True context['has_api_key'] = True
try:
game = Game.objects.filter(user=user, active=True) game = Game.objects.filter(user=user, active=True)
if game and game.exists(): if game and game.exists():
game = game.first() game = game.first()
@ -49,6 +50,8 @@ class HomePageView(TemplateView):
if not round.guess_lat or not round.guess_lng: if not round.guess_lat or not round.guess_lng:
context['existing_round'] = round context['existing_round'] = round
break break
except:
pass
else: else:
context['has_api_key'] = False context['has_api_key'] = False
return context return context
@ -79,7 +82,7 @@ class ContributeView(views.LoginRequiredMixin, CreateView):
self.object = form.save(commit=False) self.object = form.save(commit=False)
self.object.user = self.request.user self.object.user = self.request.user
self.object.save() 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()) return redirect(self.get_success_url())