当前位置: 首页>>代码示例>>Python>>正文


Python Game.nearest_game方法代码示例

本文整理汇总了Python中HVZ.main.models.Game.nearest_game方法的典型用法代码示例。如果您正苦于以下问题:Python Game.nearest_game方法的具体用法?Python Game.nearest_game怎么用?Python Game.nearest_game使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在HVZ.main.models.Game的用法示例。


在下文中一共展示了Game.nearest_game方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: save

# 需要导入模块: from HVZ.main.models import Game [as 别名]
# 或者: from HVZ.main.models.Game import nearest_game [as 别名]
    def save(self, commit=False):
        def grab(s):
            return self.cleaned_data[s]

        game = Game.nearest_game()
        player = Player.user_to_player(self.user, game)

        self.thread = Thread(
            game=game,
            team=grab('team'),
            title=grab('title'),
            slug=slugify(grab('title')),
        )

        self.thread.save()

        post = Post(
            author=player,
            thread=self.thread,
            body=grab('post_body'),
            created=settings.NOW(),
        )

        if commit:
            post.save()

        return self.thread
开发者ID:Mongoose1021,项目名称:claremontHvZ,代码行数:29,代码来源:forms.py

示例2: game

# 需要导入模块: from HVZ.main.models import Game [as 别名]
# 或者: from HVZ.main.models.Game import nearest_game [as 别名]
    def game(self):
        if self._game:
            return self._game
        try:
            self._game = Game.nearest_game()
        except Game.DoesNotExist:
            raise PermissionDenied("You need to create a game!")

        return self._game
开发者ID:Mongoose1021,项目名称:claremontHvZ,代码行数:11,代码来源:mixins.py

示例3: get_context_data

# 需要导入模块: from HVZ.main.models import Game [as 别名]
# 或者: from HVZ.main.models.Game import nearest_game [as 别名]
    def get_context_data(self, **kwargs):
        context = super(PlayerListView, self).get_context_data(**kwargs)
        context['game_season'] = Game.nearest_game().season()

        context['schools'] = School.objects.all().annotate(
            num_players=Count('player_set')
        ).order_by('-num_players')

        context['years'] = map(str, sorted(set([p.grad_year for p in Player.current_players()])))
        context['school'] = self.kwargs.get('school', '')
        context['gradyear'] = self.kwargs.get('gradyear', '')

        return context
开发者ID:Mongoose1021,项目名称:claremontHvZ,代码行数:15,代码来源:views.py

示例4: inject_outbreak_percentage

# 需要导入模块: from HVZ.main.models import Game [as 别名]
# 或者: from HVZ.main.models.Game import nearest_game [as 别名]
def inject_outbreak_percentage(request):
    try:
        newest_game = Game.nearest_game()
    except Game.DoesNotExist:
        # Just return an arbitrary sane value
        return {'outbreak_percent': 96}

    players = Player.objects.filter(game=newest_game)
    humans = players.filter(team='H')

    nPlayers = players.count()

    if nPlayers > 0:
        percent = humans.count() * 100. / nPlayers
    else:
        percent = 100

    return {'outbreak_percent': min(96, percent)}
开发者ID:Mongoose1021,项目名称:claremontHvZ,代码行数:20,代码来源:context_processors.py

示例5: get_queryset

# 需要导入模块: from HVZ.main.models import Game [as 别名]
# 或者: from HVZ.main.models.Game import nearest_game [as 别名]
 def get_queryset(self):
     return Player.objects.all().filter(game=Game.nearest_game())
开发者ID:JoshPetrack,项目名称:claremontHvZ,代码行数:4,代码来源:views.py

示例6: get_queryset

# 需要导入模块: from HVZ.main.models import Game [as 别名]
# 或者: from HVZ.main.models.Game import nearest_game [as 别名]
 def get_queryset(self):
     game = Game.nearest_game()
     return Player.objects.filter(game=game)
开发者ID:Mongoose1021,项目名称:claremontHvZ,代码行数:5,代码来源:views.py


注:本文中的HVZ.main.models.Game.nearest_game方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。