示例#1
0
    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
示例#2
0
 def get_queryset(self):
     game = Game.nearest_game()
     team = self.player.team
     return Plot.get_visible(game, team).select_related('mission')
示例#3
0
 def get_queryset(self):
     return Plot.get_visible(
         self.game,
         self.player.team
     ).select_related('mission').all()
示例#4
0
from HVZ.basetest import BaseTest, HUGH_MANN, ROB_ZOMBIE
from HVZ.main.models import Player, Game
from HVZ.missions.models import Mission, Plot

MISSION = Mission(
    day=settings.NOW().date(),
    time="N",
)

ZOMBIE_PLOT = Plot(
    title="Tonight, we dine in Hell!",
    slug="tonight-we-dine-in-hell",
    team='Z',
    before_story="Nommin' in Nam.",
    before_story_markup_type="markdown",
    victory_story="Zombies done won.",
    victory_story_markup_type="markdown",
    defeat_story="Zombies done lost.",
    defeat_story_markup_type="markdown",
    visible=True,
)

HUMAN_PLOT = Plot(
    title="Friends, Romans, Countrymen.",
    slug="friends-romans-countrymen",
    team='H',
    before_story="Lend me your ears",
    before_story_markup_type="markdown",
    victory_story="Humans done won.",
    victory_story_markup_type="markdown",
    defeat_story="Humans done lost.",