本文整理匯總了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)