本文整理匯總了Python中models.Course.find_by_id方法的典型用法代碼示例。如果您正苦於以下問題:Python Course.find_by_id方法的具體用法?Python Course.find_by_id怎麽用?Python Course.find_by_id使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類models.Course
的用法示例。
在下文中一共展示了Course.find_by_id方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: get_sole_course_and_user_information
# 需要導入模塊: from models import Course [as 別名]
# 或者: from models.Course import find_by_id [as 別名]
def get_sole_course_and_user_information(sole_id, user_id=None):
db = MongoClient()
# find the sole
sole = Sole.find_by_id(db, sole_id)
if not sole:
None, None, None
# find the course
cid = sole.get(Sole.A_COURSE_ID)
course = Course.find_by_id(db, cid)
if not course:
sole, None, None
# find the user who did the action
user_ids = set(sole.get(Sole.A_STUDENT_IDS))
if not user_ids:
# everyone has left the group!
sole, course, None
if user_id:
user_ids.add(user_id)
users = User.find_by_ids(db, user_ids, as_dict=True)
return sole, course, users