本文整理汇总了Python中HVZ.main.models.Game.games方法的典型用法代码示例。如果您正苦于以下问题:Python Game.games方法的具体用法?Python Game.games怎么用?Python Game.games使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类HVZ.main.models.Game
的用法示例。
在下文中一共展示了Game.games方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: inject_outbreak_percentage
# 需要导入模块: from HVZ.main.models import Game [as 别名]
# 或者: from HVZ.main.models.Game import games [as 别名]
def inject_outbreak_percentage(request):
try:
latest_game = Game.games(started=True).latest()
except Game.DoesNotExist:
# Just return an arbitrary sane value
return {'outbreak_percent': 96}
players = Player.objects.filter(game=latest_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)}
示例2: get_context_data
# 需要导入模块: from HVZ.main.models import Game [as 别名]
# 或者: from HVZ.main.models.Game import games [as 别名]
def get_context_data(self, *args, **kwargs):
context = super(LandingPage, self).get_context_data(*args, **kwargs)
if not self.request.user.is_authenticated():
form = PrettyAuthForm()
else:
form = None
context['login_form'] = form
context['is_landing_page'] = True
try:
context['latest_meals'] = (
Meal.objects.filter(
eater__game=Game.games(started=True).latest(),
).order_by('-time')[:20])
except Game.DoesNotExist:
context['latest_meals'] = []
return context
示例3: wrapper
# 需要导入模块: from HVZ.main.models import Game [as 别名]
# 或者: from HVZ.main.models.Game import games [as 别名]
def wrapper(*args, **kwargs):
if not Game.games(finished=False).exists():
raise NoUnfinishedGames
return view_func(*args, **kwargs)
示例4: wrapper
# 需要导入模块: from HVZ.main.models import Game [as 别名]
# 或者: from HVZ.main.models.Game import games [as 别名]
def wrapper(*args, **kwargs):
if not Game.games(started=True, finished=False).exists():
raise NoActiveGame
return view_func(*args, **kwargs)