當前位置: 首頁>>代碼示例>>Python>>正文


Python Course.list_for_enroll方法代碼示例

本文整理匯總了Python中enroll.models.Course.list_for_enroll方法的典型用法代碼示例。如果您正苦於以下問題:Python Course.list_for_enroll方法的具體用法?Python Course.list_for_enroll怎麽用?Python Course.list_for_enroll使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在enroll.models.Course的用法示例。


在下文中一共展示了Course.list_for_enroll方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: get_offer_list

# 需要導入模塊: from enroll.models import Course [as 別名]
# 或者: from enroll.models.Course import list_for_enroll [as 別名]
def get_offer_list(folder_id = None):

    if folder_id is None:
        folders_query=Folder.list()
    else:
        folders_query = []
        f = Folder.get_by_id(int(folder_id))
        if f:
            folders_query.append(f)
    
    courses_query=Course.list_for_enroll()  

    folders= set([])
    courses = []
    result = []
    for course in courses_query:
        folders.add(course.folder_key)
        courses.append(course)

    logging.info(folders)
    logging.info(courses)

    for folder in folders_query:
        fk = str(folder.key())
        logging.info('fk:%s'%fk)
        if fk in folders:
            logging.info('in')
            sub_list = [c for c in courses if fk==c.folder_key] 
            result.append({'folder':folder, 'courses':sub_list })
            pass
    return result
開發者ID:,項目名稱:,代碼行數:33,代碼來源:

示例2: get_offer_list2

# 需要導入模塊: from enroll.models import Course [as 別名]
# 或者: from enroll.models.Course import list_for_enroll [as 別名]
def get_offer_list2():
    courses_query=Course.list_for_enroll()  
    folder_courses= dict()
    result = []
    for course in courses_query:
        folder_courses.setdefault(course.folder_key,[]).append(course)         

    result=[]
    folders_query=Folder.list()
    for folder in folders_query:
        if str(folder.key()) in folder_courses:
            result.append({'folder':folder, 'courses':folder_courses[str(folder.key())]})
            
    logging.info(result)
   
    return result
開發者ID:,項目名稱:,代碼行數:18,代碼來源:


注:本文中的enroll.models.Course.list_for_enroll方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。