本文整理汇总了Python中api_db_utils.APIDB.get_club_courses_im_subscribed_to方法的典型用法代码示例。如果您正苦于以下问题:Python APIDB.get_club_courses_im_subscribed_to方法的具体用法?Python APIDB.get_club_courses_im_subscribed_to怎么用?Python APIDB.get_club_courses_im_subscribed_to使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类api_db_utils.APIDB
的用法示例。
在下文中一共展示了APIDB.get_club_courses_im_subscribed_to方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: trainee_course_list
# 需要导入模块: from api_db_utils import APIDB [as 别名]
# 或者: from api_db_utils.APIDB import get_club_courses_im_subscribed_to [as 别名]
def trainee_course_list(req, uskey_club):
"""
``GET`` @ |ta| + ``/clubs/<uskey_club>/courses``
List of the courses of a club
"""
club = req.model
j_req = json_from_paginated_request(req, (('course_type', None), 'activeOnly', ('subscribed', False)))
page = int(j_req['page'])
size = int(j_req['size'])
course_type = j_req['course_type']
active_only = j_req['activeOnly'] == "True"
subscribed = j_req['subscribed'] == "True"
if subscribed:
courses, total = APIDB.get_club_courses_im_subscribed_to(club, course_type=course_type, active_only=active_only,
paginated=True, page=page, size=size)
else:
courses, total = APIDB.get_club_courses(club, course_type=course_type, active_only=active_only,
paginated=True, page=page, size=size)
res_courses = []
for course in courses:
j_course = course.to_dict()
j_course["trainers"] = sanitize_list(APIDB.get_course_trainers(course), allowed=["id", "name", "picture"])
j_course["subscriber_count"] = APIDB.get_course_subscribers(course, count_only=True)
j_course["session_count"] = APIDB.get_course_sessions(course, count_only=True)
allowed = ["id", "name", "description", "trainers", "subscriber_count", "session_count", "course_type"]
if course.course_type == "SCHEDULED":
allowed += ["start_date", "end_date"]
elif course.course_type == "PROGRAM":
allowed += ["week_no", "day_no"]
res_course = sanitize_json(j_course, allowed=allowed)
res_courses.append(res_course)
ret = {}
ret['results'] = res_courses
ret['total'] = total
return ret