本文整理汇总了Python中openedx.core.djangoapps.site_configuration.models.SiteConfiguration.get_configuration_for_org方法的典型用法代码示例。如果您正苦于以下问题:Python SiteConfiguration.get_configuration_for_org方法的具体用法?Python SiteConfiguration.get_configuration_for_org怎么用?Python SiteConfiguration.get_configuration_for_org使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类openedx.core.djangoapps.site_configuration.models.SiteConfiguration
的用法示例。
在下文中一共展示了SiteConfiguration.get_configuration_for_org方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_get_site_for_org
# 需要导入模块: from openedx.core.djangoapps.site_configuration.models import SiteConfiguration [as 别名]
# 或者: from openedx.core.djangoapps.site_configuration.models.SiteConfiguration import get_configuration_for_org [as 别名]
def test_get_site_for_org(self):
"""
Test that get_value_for_org returns correct value for any given key.
"""
# add SiteConfiguration to database
config1 = SiteConfigurationFactory.create(
site=self.site,
values=self.test_config1,
)
config2 = SiteConfigurationFactory.create(
site=self.site2,
values=self.test_config2,
)
# Make sure entry is saved and retrieved correctly
self.assertEqual(
SiteConfiguration.get_configuration_for_org(self.test_config1['course_org_filter']),
config1,
)
self.assertEqual(
SiteConfiguration.get_configuration_for_org(self.test_config2['course_org_filter']),
config2,
)
self.assertEqual(
SiteConfiguration.get_configuration_for_org('something else'),
None,
)
示例2: _site_from_org
# 需要导入模块: from openedx.core.djangoapps.site_configuration.models import SiteConfiguration [as 别名]
# 或者: from openedx.core.djangoapps.site_configuration.models.SiteConfiguration import get_configuration_for_org [as 别名]
def _site_from_org(cls, org):
configuration = SiteConfiguration.get_configuration_for_org(org, select_related=['site'])
if configuration is None:
try:
return Site.objects.get(id=settings.SITE_ID)
except Site.DoesNotExist:
return RequestSite(crum.get_current_request())
else:
return configuration.site