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


Python APIDB.add_trainer_to_course方法代码示例

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


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

示例1: coach_course_create

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

    Create a course for the club. |uroleOT|
    """
    j_req = json_from_request(req, mandatory_props=["name", "description", "courseType", "maxLevel"],
                              optional_props=["startDate", "endDate", "duration", "profile"])
    try:
        if "startDate" in j_req:
            j_req['startDate'] = datetime.datetime.fromtimestamp(long(j_req['startDate']) / 1000)
    except Exception as e:
        raise BadParameters("startDate is not a correct date")
        # j_req['startDate'] = datetime.datetime.now()
    try:
        if "startDate" in j_req:
            j_req['endDate'] = datetime.datetime.fromtimestamp(long(j_req['endDate']) / 1000)
    except Exception as e:
        raise BadParameters("endDate is not a correct date")
    if "duration" in j_req:
        j_req['duration'] = int(j_req['duration'])
    course = APIDB.create_course(req.model, **j_req)
    APIDB.add_trainer_to_course(req.user, course)
    req.model = course
    return coach_course_detail(req, uskey_club)
开发者ID:gymcentral,项目名称:gymcentral,代码行数:27,代码来源:api_coach.py

示例2: coach_course_subscription_create

# 需要导入模块: from api_db_utils import APIDB [as 别名]
# 或者: from api_db_utils.APIDB import add_trainer_to_course [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

示例3: Key

# 需要导入模块: from api_db_utils import APIDB [as 别名]
# 或者: from api_db_utils.APIDB import add_trainer_to_course [as 别名]
user = User.query(User.email == '[email protected]').get()
club = APIDB.create_club(name="gymCentral Free Club",
                         description="This club is provided by gymCentral, with a free demo course for everyone who wants to feel the experience of our service.",
                         is_open=True, url="http://gymcentral.net")
# club created
# club = Key('Club',6192449487634432).get()
APIDB.add_owner_to_club(user, club)
# APIDB.add_trainer_to_club(iman, club,status="ACCEPTED")
# Course
data = dict(name="Strength and balance", description="Free course to improve your strength and balance.",
            start_date=date_to_js_timestamp(datetime(2015, 1, 1)),
            end_date=date_to_js_timestamp(datetime(2015, 12, 31)),
            course_type="SCHEDULED", max_level=2)
course = APIDB.create_course(club, **data)
APIDB.add_trainer_to_course(user, course)
# Course created
# course = Key('Course',4785074604081152).get()
# Indicators
data = dict(name="How are you today?", indicator_type="INTEGER", description="How are you today", required=True,
            answer_type='CHECKBOXES',
            possible_answers=[dict(name='1', text='Very bad', value='1'), dict(name='2', text='Not so good', value='2'),
                              dict(name='3', text='Ok', value='3'), dict(name='4', text='Good', value='4'),
                              dict(name='5', text='Very good', value='5')])
how_are_you = APIDB.create_indicator(club, **data)
# how_are_you = Key('Indicator',5275456790069248).get()
data = dict(name="How was the session?", indicator_type="INTEGER", description="How was the session", required=True,
            answer_type='CHECKBOXES',
            possible_answers=[dict(name='e', text='easy', value='-1'), dict(name='m', text='medium', value='0'),
                              dict(name='h', text='hard', value='1')])
how_was_session = APIDB.create_indicator(club, **data)
开发者ID:gymcentral,项目名称:gymcentral,代码行数:32,代码来源:creation_script.py


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