本文整理汇总了Python中models.Profile.get_profile_from_user方法的典型用法代码示例。如果您正苦于以下问题:Python Profile.get_profile_from_user方法的具体用法?Python Profile.get_profile_from_user怎么用?Python Profile.get_profile_from_user使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Profile
的用法示例。
在下文中一共展示了Profile.get_profile_from_user方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: cancel_game
# 需要导入模块: from models import Profile [as 别名]
# 或者: from models.Profile import get_profile_from_user [as 别名]
def cancel_game(self, request):
"""
Cancels a Blackjack Marathon game based on key.
"""
profile_key = Profile.get_profile_from_user().key
Game.cancel_game(profile_key, request.urlsafe_game_key)
return StringMessage(message='Game cancelled successfully.')
示例2: new_game
# 需要导入模块: from models import Profile [as 别名]
# 或者: from models.Profile import get_profile_from_user [as 别名]
def new_game(self, request):
"""
Creates a new Blackjack Marathon game for a user.
"""
profile = Profile.get_profile_from_user()
game = Game.new_game(p_key=profile.key)
game.put()
return game.to_form('Good luck playing Blackjack Marathon!')
示例3: get_user_games
# 需要导入模块: from models import Profile [as 别名]
# 或者: from models.Profile import get_profile_from_user [as 别名]
def get_user_games(self, request):
"""Return the user's active games."""
profile = Profile.get_profile_from_user()
# Create ancestor query for all key matches for this user.
# Filter on games where points_remaining > 0
games = Game.query(ancestor=profile.key). \
filter(Game.points_remaining > 0)
# return set of GameForm objects per game
return GameForms(
items=[game.to_form() for game in games]
)
示例4: make_move
# 需要导入模块: from models import Profile [as 别名]
# 或者: from models.Profile import get_profile_from_user [as 别名]
def make_move(self, request):
"""
Makes a move on a given Blackjack Marathon game. The move is the user's
chosen strategy based on the current player and Dealer card hands.
"""
# Verify the strategy passed in
if request.strategy not in STRATEGIES:
raise endpoints.BadRequestException('Invalid strategy {} '
'passed in'.format(
request.strategy))
return Game.apply_strategy(Profile.get_profile_from_user().key,
request.urlsafe_game_key,
request.strategy)
示例5: get_profile
# 需要导入模块: from models import Profile [as 别名]
# 或者: from models.Profile import get_profile_from_user [as 别名]
def get_profile(self, request):
"""Return user profile."""
profile = Profile.get_profile_from_user()
return profile.to_form()