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


Python APIDB.user_participation_details方法代码示例

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


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

示例1: trainee_club_session_list_ongoing

# 需要导入模块: from api_db_utils import APIDB [as 别名]
# 或者: from api_db_utils.APIDB import user_participation_details [as 别名]
def trainee_club_session_list_ongoing(req, uskey_club):
    """
    ``GET`` @ |ta| +  ``/clubs/<uskey_course>/sessions``

    List of the session of a club. |uroleM|
    """
    # TODO: test
    club = req.model
    # j_req = json_from_request(req)
    # session_type = j_req['type']
    sessions = APIDB.get_sessions_im_subscribed(req.user, club, paginated=False)

    res_list = []
    for session in sessions:
        if session.status == "ONGOING":
            res_obj = session.to_dict()
            res_obj['status'] = session.status
            res_obj['participated'] = APIDB.user_participated_in_session(req.user, session)
            res_obj['participation_count'] = APIDB.user_participation_details(req.user, session, count_only=True)
            res_obj['max_score'] = APIDB.session_completeness(req.user, session)
            course = session.course.get()
            res_obj['course_id'] = course.id
            res_obj['course_name'] = course.name
            # no edist here, since the data on the type are already removed
            return sanitize_json(res_obj, hidden=['course', 'list_exercises', 'profile', 'activities', 'on_before',
                                                  'on_after', 'meta_data'])
    return dict()
开发者ID:gymcentral,项目名称:gymcentral,代码行数:29,代码来源:api_trainee.py

示例2: trainee_course_session_list

# 需要导入模块: from api_db_utils import APIDB [as 别名]
# 或者: from api_db_utils.APIDB import user_participation_details [as 别名]
def trainee_course_session_list(req, uskey_course):
    """
    ``GET`` @ |ta| +  ``/courses/<uskey_course>/sessions``

    List of the session of a course. |uroleM|
    """
    # TODO: test
    course = req.model
    j_req = json_from_paginated_request(req, (('status', 'UPCOMING'), ('type', None),
                                              ('from', None),
                                              ('to', None)))

    page = int(j_req['page'])
    size = int(j_req['size'])
    try:
        date_from = datetime.datetime.fromtimestamp(long(j_req['from']) / 1000)
    except Exception as e:
        date_from = None
    try:
        date_to = datetime.datetime.fromtimestamp(long(j_req['to']) / 1000)
    except Exception as e:
        date_to = None
    session_type = j_req['type']

    sessions, total = APIDB.get_course_sessions(course, date_from=date_from, date_to=date_to, session_type=session_type,
                                                paginated=True, page=page, size=size)
    res_list = []
    for session in sessions:
        res_obj = session.to_dict()
        res_obj['status'] = session.status
        res_obj['participated'] = APIDB.user_participated_in_session(req.user, session)
        res_obj['participation_count'] = APIDB.user_participation_details(req.user, session, count_only=True)
        # res_obj['actnoivity_count'] = session.activity_count
        res_obj['max_score'] = APIDB.session_completeness(req.user, session)
        allowed = ['id', 'name', 'status', 'participation_count',
                   'session_type']
        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_list.append(sanitize_json(res_obj, allowed=allowed))

    return dict(total=total, results=res_list)
开发者ID:gymcentral,项目名称:gymcentral,代码行数:48,代码来源:api_trainee.py

示例3: trainee_session_detail

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

    Detail of a session |uroleM|
    """
    session = req.model
    j_session = session.to_dict()
    j_session['participation_count'] = APIDB.user_participation_details(req.user, 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", 'id'])
    j_session['on_after'] = sanitize_list(APIDB.get_session_indicator_after(session),
                                          allowed=["name", "indicator_type", "description", "possible_answers",
                                                   "required", 'id'])
    activities = APIDB.get_session_user_activities(session, req.user)
    res_list = []
    for activity in activities:
        j_activity = activity.to_dict()
        level = APIDB.get_user_level_for_activity(req.user, activity, session)
        j_activity['level'] = level.level_number
        j_activity['description'] = level.description
        j_activity['source'] = level.source
        j_activity['indicators'] = sanitize_list(activity.indicators,
                                                 allowed=["name", "indicator_type", "description", "possible_answers",
                                                          "required", 'id'])
        # this is already a json, see docs in the model
        j_activity['details'] = level.details
        res_list.append(j_activity)
    j_session['max_score'] = APIDB.session_completeness(req.user, session)
    j_session['activities'] = sanitize_list(res_list,
                                            allowed=['id', 'name', 'description', 'level', 'source', 'details',
                                                     'indicators'])
    # there should be 'type',
    allowed = ['id', 'name', 'status', 'participation_count',
               'activities', 'session_type', 'max_score', 'on_before', 'on_after']
    course_type = session.course.get().course_type
    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,代码行数:47,代码来源:api_trainee.py

示例4: trainee_club_session_list

# 需要导入模块: from api_db_utils import APIDB [as 别名]
# 或者: from api_db_utils.APIDB import user_participation_details [as 别名]
def trainee_club_session_list(req, uskey_club):
    """
    ``GET`` @ |ta| +  ``/clubs/<uskey_course>/sessions``

    List of the session of a club. |uroleM|
    """
    # TODO: test
    club = req.model
    j_req = json_from_paginated_request(req, (('type', None),
                                              ('from', None),
                                              ('to', None)))
    page = int(j_req['page'])
    size = int(j_req['size'])
    try:
        date_from = datetime.datetime.fromtimestamp(long(j_req['from']) / 1000)
    except Exception as e:
        date_from = None
    try:
        date_to = datetime.datetime.fromtimestamp(long(j_req['to']) / 1000)
    except Exception as e:
        date_to = None
    session_type = j_req['type']
    sessions, total = APIDB.get_sessions_im_subscribed(req.user, club, date_from, date_to, session_type, paginated=True,
                                                       page=page, size=size)

    res_list = []
    for session in sessions:
        res_obj = session.to_dict()
        res_obj['status'] = session.status
        res_obj['participated'] = APIDB.user_participated_in_session(req.user, session)
        res_obj['participation_count'] = APIDB.user_participation_details(req.user, session, count_only=True)
        res_obj['max_score'] = APIDB.session_completeness(req.user, session)
        course = session.course.get()
        res_obj['course_id'] = course.id
        res_obj['course_name'] = course.name
        # no edist here, since the data on the type are already removed
        res_list.append(sanitize_json(res_obj, hidden=['course', 'list_exercises', 'profile', 'activities', 'on_before',
                                                       'on_after', 'meta_data']))
    return dict(total=total, results=res_list)
开发者ID:gymcentral,项目名称:gymcentral,代码行数:41,代码来源:api_trainee.py


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