本文整理汇总了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
示例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
示例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
示例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)}
示例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())
示例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)