def get_context_data(self, **kwargs): context = super(PlotDetailView, self).get_context_data(**kwargs) context['story'] = context['plot'].get_story(self.player.team) context['plot_list'] = Plot.get_visible( self.game, self.player.team ).select_related('mission').all() context['plots_sorted'] = sorted( list(context['plot_list']), key=lambda plot: plot.mission.start_time(), reverse=True ) # Check that the player is authorized to see the object plot = context['plot'] team = plot.team if self.player.team != team and plot.mission.game.is_unfinished(): team_name = "human" if team == 'H' else "zombie" raise PermissionDenied( "You must be a {} to view this page.".format(team_name) ) if not plot.is_visible(): raise Http404 return context
def get_queryset(self): return Plot.get_visible( self.game, self.player.team ).select_related('mission').all()
def get_queryset(self): game = Game.nearest_game() team = self.player.team return Plot.get_visible(game, team).select_related('mission')