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


Python APIDB.get_session_exercises方法代码示例

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


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

示例1: coach_course_subscription_details

# 需要导入模块: from api_db_utils import APIDB [as 别名]
# 或者: from api_db_utils.APIDB import get_session_exercises [as 别名]
def coach_course_subscription_details(req, uskey_subscription):
    """
    ``GET`` @ |ca| +  ``/subscriptions/<uskey_subscription>``

    GET a subscription. |uroleOT|
    """
    subscription = req.model
    user = subscription.member.get()

    res = sanitize_json(subscription.to_dict(), ['id', 'start_date', 'profile_level', 'observations', 'disabled_exercises','max_level','profile'])
    res['user'] = sanitize_json(user, ['id', 'name', 'picture'])
    sessions = APIDB.get_course_sessions(subscription.course.get())
    res_list = []
    added_activities = []
    for session in sessions:
        activities = APIDB.get_session_exercises(session)
        for activity in activities:
            if activity.id not in added_activities:
                added_activities.append(activity.id)
                j_activity = activity.to_dict()
                level_count = len(activity.levels)
                j_activity['level_count'] = level_count
            # this is already a json, see docs in the model
                res_list.append(j_activity)
    res['activities'] = sanitize_list(res_list,allowed=['id', 'name', 'level_count'])
    return res
开发者ID:gymcentral,项目名称:gymcentral,代码行数:28,代码来源:api_coach.py

示例2: coach_session_detail

# 需要导入模块: from api_db_utils import APIDB [as 别名]
# 或者: from api_db_utils.APIDB import get_session_exercises [as 别名]
def coach_session_detail(req, uskey_session):
    """
    ``GET`` @ |ca| +  ``/sessions/<uskey_session>``

    Detail of a session. |uroleOT|
    """
    session = req.model
    j_session = session.to_dict()
    j_session['participation_count'] = APIDB.get_session_participations(session, count_only=True)
    j_session['status'] = session.status
    j_session['on_before'] = sanitize_list(APIDB.get_session_indicator_before(session),
                                           allowed=["name", "indicator_type", "description", "possible_answers",
                                                    "required"])
    j_session['on_after'] = sanitize_list(APIDB.get_session_indicator_after(session),
                                          allowed=["name", "indicator_type", "description", "possible_answers",
                                                   "required"])
    activities = APIDB.get_session_exercises(session)
    res_list = []
    for activity in activities:
        j_activity = activity.to_dict()
        level_count = len(activity.levels)
        j_activity['level_count'] = level_count

        # this is already a json, see docs in the model
        res_list.append(j_activity)
    j_session['activities'] = sanitize_list(res_list,
                                            allowed=['id', 'name', 'level_count'])

    # there should be 'type',x
    allowed = ['id', 'name', 'status', 'participation_count',
               'activities', 'session_type', 'meta_data', 'on_before', 'on_after', 'created', 'max_level', 'profile']
    course_type = session.course.get().course_type
    if session.session_type == "SINGLE":
        allowed += ['url']
    if course_type == "SCHEDULED":
        allowed += ["start_date", "end_date"]
    elif course_type == "PROGRAM":
        allowed += ["week_no", "day_no"]
    res = sanitize_json(j_session,
                        allowed=allowed)
    return res
开发者ID:gymcentral,项目名称:gymcentral,代码行数:43,代码来源:api_coach.py


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