def new_dispatch(self, request, *args, **kwargs): response = orig_dispatch(self, request, *args, **kwargs) player = Player.get_player(request) # Only allow proceeding to the next puzzle if player.last_puzzle != get_last_puzzle(): next_puzzle = get_next_puzzle(player.last_puzzle) if next_puzzle == cls.puzzle_name: SolvedPuzzle.objects.create(player=player, puzzle=next_puzzle, timestamp=timezone.now()) elif puzzle_less(player.last_puzzle, cls.puzzle_name): raise Http404 response.set_cookie('sid', player.session_id, expires=timezone.now() + timezone.timedelta(days=365)) return response
def get_initial(self): player = Player.get_player(self.request) return { 'email': player.email, }
def form_valid(self, form): player = Player.get_player(self.request) player.email = form.cleaned_data['email'] player.save() return super().form_valid(form)