本文整理汇总了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]