本文整理汇总了Python中api_db_utils.APIDB.add_member_to_club方法的典型用法代码示例。如果您正苦于以下问题:Python APIDB.add_member_to_club方法的具体用法?Python APIDB.add_member_to_club怎么用?Python APIDB.add_member_to_club使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类api_db_utils.APIDB
的用法示例。
在下文中一共展示了APIDB.add_member_to_club方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: coach_club_membership_create
# 需要导入模块: from api_db_utils import APIDB [as 别名]
# 或者: from api_db_utils.APIDB import add_member_to_club [as 别名]
def coach_club_membership_create(req, uskey_club):
"""
``POST`` @ |ca| + ``/clubs/<uskey_club>/memberships``
Add a membership for the user specified in the body ``userId``. |uroleOT|
"""
# FIXME: how delete works?
j_req = json_from_request(req, ["userId", "membershipType"], [("endDate", None)])
user = APIDB.get_user_by_id(j_req['user_id'])
membership_type = j_req.pop('membership_type')
if membership_type == "MEMBER":
APIDB.add_member_to_club(user, req.model, status="ACCEPTED", end_date=j_req['end_date'])
elif membership_type == "TRAINER":
APIDB.add_trainer_to_club(user, req.model, status="ACCEPTED", end_date=j_req['end_date'])
elif membership_type == "OWNER":
APIDB.add_owner_to_club(user, req.model, end_date=j_req['end_date'])
else:
raise BadParameters("Value %s is not valid for field 'type'" % j_req['type'])
req.model = APIDB.get_membership(user, req.model)
return HttpCreated(coach_club_membership(req, None))