当前位置: 首页>>代码示例>>Python>>正文


Python APIDB.get_user_by_id方法代码示例

本文整理汇总了Python中api_db_utils.APIDB.get_user_by_id方法的典型用法代码示例。如果您正苦于以下问题:Python APIDB.get_user_by_id方法的具体用法?Python APIDB.get_user_by_id怎么用?Python APIDB.get_user_by_id使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在api_db_utils.APIDB的用法示例。


在下文中一共展示了APIDB.get_user_by_id方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: coach_course_subscription_create

# 需要导入模块: from api_db_utils import APIDB [as 别名]
# 或者: from api_db_utils.APIDB import get_user_by_id [as 别名]
def coach_course_subscription_create(req, uskey_course):
    """
    ``POST`` @ |ca| +  ``/courses/<uskey_course>/subscriptions``

    Creates a subscription for the coruse. |uroleOT|
    """
    course = req.model
    j_req = json_from_request(req, mandatory_props=['userId', 'role'],
                              optional_props=['profileLevel'])
    user = APIDB.get_user_by_id(j_req['user_id'])
    if j_req['role'] == "MEMBER":
        if 'profile_level' not in j_req:
            raise BadParameters("profileLevel is missing")
        APIDB.add_member_to_course(user, course, status="ACCEPTED", profile_level=j_req['profile_level'])
    elif j_req['role'] == "TRAINER":  # only owners can add coaches
        # if not APIDB.get_user_club_role(req.user, course.club) == "OWNER":
        # raise AuthenticationError("User is not a OWNER")
        APIDB.add_trainer_to_course(user, course)
    return HttpEmpty()
开发者ID:gymcentral,项目名称:gymcentral,代码行数:21,代码来源:api_coach.py

示例2: coach_club_membership_create

# 需要导入模块: from api_db_utils import APIDB [as 别名]
# 或者: from api_db_utils.APIDB import get_user_by_id [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))
开发者ID:gymcentral,项目名称:gymcentral,代码行数:22,代码来源:api_coach.py


注:本文中的api_db_utils.APIDB.get_user_by_id方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。