本文整理汇总了Python中models.Team.get_or_add_team方法的典型用法代码示例。如果您正苦于以下问题:Python Team.get_or_add_team方法的具体用法?Python Team.get_or_add_team怎么用?Python Team.get_or_add_team使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Team
的用法示例。
在下文中一共展示了Team.get_or_add_team方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_or_add_team
# 需要导入模块: from models import Team [as 别名]
# 或者: from models.Team import get_or_add_team [as 别名]
def get_or_add_team():
"""
"""
team_name = request.json['team_name']
team_id = Team.get_or_add_team(team_name)
return jsonify({'team_id': team_id})
示例2: add_player_stats
# 需要导入模块: from models import Team [as 别名]
# 或者: from models.Team import get_or_add_team [as 别名]
def add_player_stats():
data = request.json['stats']
player_name = data['player_name']
team_name = data['team_name']
stats_type = request.json['stat_type']
team_id = Team.get_or_add_team(team_name)
player_id = Player.get_or_add_player(player_name, team_id)
data['player_id'] = player_id[0]
if stats_type == 'Rushing':
class_type = RushingStat
elif stats_type == 'Passing':
class_type = PassingStat
elif stats_type == 'Receiving':
class_type = ReceivingStat
elif stats_type == 'Defense':
class_type = DefensiveStat
class_type.add_stat(**data)
return jsonify({'player_id': player_id})