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


Python MicrositeConfiguration.get_all_microsite_orgs方法代码示例

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


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

示例1: get_visible_courses

# 需要导入模块: from microsite_configuration.middleware import MicrositeConfiguration [as 别名]
# 或者: from microsite_configuration.middleware.MicrositeConfiguration import get_all_microsite_orgs [as 别名]
def get_visible_courses():
    """
    Return the set of CourseDescriptors that should be visible in this branded instance
    """
    _courses = modulestore().get_courses()

    courses = [c for c in _courses
               if isinstance(c, CourseDescriptor)]
    courses = sorted(courses, key=lambda course: course.number)

    subdomain = MicrositeConfiguration.get_microsite_configuration_value('subdomain', 'default')

    # See if we have filtered course listings in this domain
    filtered_visible_ids = None

    # this is legacy format which is outside of the microsite feature -- also handle dev case, which should not filter
    if hasattr(settings, 'COURSE_LISTINGS') and subdomain in settings.COURSE_LISTINGS and not settings.DEBUG:
        filtered_visible_ids = frozenset(settings.COURSE_LISTINGS[subdomain])

    filtered_by_org = MicrositeConfiguration.get_microsite_configuration_value('course_org_filter')

    if filtered_by_org:
        return [course for course in courses if course.location.org == filtered_by_org]
    if filtered_visible_ids:
        return [course for course in courses if course.id in filtered_visible_ids]
    else:
        # Let's filter out any courses in an "org" that has been declared to be
        # in a Microsite
        org_filter_out_set = MicrositeConfiguration.get_all_microsite_orgs()
        return [course for course in courses if course.location.org not in org_filter_out_set]
开发者ID:YoshidaKS,项目名称:edx-platform,代码行数:32,代码来源:__init__.py


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