本文整理汇总了Python中api_db_utils.APIDB.get_course_subscription方法的典型用法代码示例。如果您正苦于以下问题:Python APIDB.get_course_subscription方法的具体用法?Python APIDB.get_course_subscription怎么用?Python APIDB.get_course_subscription使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类api_db_utils.APIDB
的用法示例。
在下文中一共展示了APIDB.get_course_subscription方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: coach_session_participations
# 需要导入模块: from api_db_utils import APIDB [as 别名]
# 或者: from api_db_utils.APIDB import get_course_subscription [as 别名]
def coach_session_participations(req, uskey_session):
"""
``GET`` @ |ca| + ``/sessions/<uskey_session>/participations``
Participation on a session. |uroleOT|
"""
session = req.model
user = req.user
j_req = json_from_paginated_request(req)
# if j_req['paginated']:
participations, total = APIDB.get_session_participations(session, paginated=True, size=j_req['size'],
page=j_req['page'])
# else:
# participations = APIDB.get_session_participations(session, paginated=True, size=j_req['size'],
# page=j_req['page'])
res_list = []
for participation in participations:
res = participation.to_dict()
res['user'] = sanitize_json(participation.user.get(), ['name', 'id', 'avatar', 'picture', 'sensors'],
except_on_missing=False)
subscription = APIDB.get_course_subscription(session.course, participation.user)
res['subscription_id'] = subscription.id
res['current_level'] = subscription.profile_level
res['level'] = participation.level
res['level_up'] = subscription.increase_level
res['indicators'] = participation.indicators
res['max_completeness'] = participation.max_completeness
res['participation_count'] = participation.participation_count
res_list.append(sanitize_json(res, ['id', 'user', 'level_up', 'current_level', 'indicators',
'max_completeness', 'completeness', 'participation_count', 'time',
'level', 'subscription_id']))
return dict(results=res_list, total=total)
示例2: coach_participations_performances
# 需要导入模块: from api_db_utils import APIDB [as 别名]
# 或者: from api_db_utils.APIDB import get_course_subscription [as 别名]
def coach_participations_performances(req, uskey_participation):
"""
``GET`` @ |ca| + ``/participations/<uskey_participation>/performances``
Perfomances of a participation. |uroleOT|
"""
participation = req.model
user = participation.user.get()
performances = APIDB.get_performances_from_participation(participation)
res_list = []
session = participation.session.get()
subscription = APIDB.get_course_subscription(session.course, user)
for performance in performances:
res_obj = performance.to_dict()
activity = performance.activity.get()
res_obj['activity'] = sanitize_json(activity, ['id', 'name'])
res_obj['indicators'] = performance.indicators
res_list.append(sanitize_json(res_obj,
['activity', 'record_date', 'completeness', 'indicators', 'max_completeness',
'level']))
d_participation = participation.to_dict()
d_participation['max_completeness'] = participation.max_completeness
d_participation['indicators'] = participation.indicators
return dict(user=sanitize_json(user, ['id', 'name', 'picture', 'sensors'], except_on_missing=False),
participation=sanitize_json(d_participation,
['id', 'max_completeness', 'completeness', 'time', 'indicators']),
subscription=sanitize_json(subscription, ['id', 'profile_level','disabled_exercises']),
session=sanitize_json(session, ['id', 'name', 'max_level']), performances=res_list)