本文整理汇总了Python中microsite_configuration.microsite.set_by_domain函数的典型用法代码示例。如果您正苦于以下问题:Python set_by_domain函数的具体用法?Python set_by_domain怎么用?Python set_by_domain使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了set_by_domain函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: test_get_all_configs
def test_get_all_configs(self):
"""
Tests microsite.get_all_config works as expected.
"""
microsite.set_by_domain(self.microsite_subdomain)
configs = microsite.get_all_config()
self.assertEqual(len(configs.keys()), 3)
开发者ID:Endika,项目名称:edx-platform,代码行数:7,代码来源:test_filebased.py
示例2: test_microsite_get_template
def test_microsite_get_template(self):
"""
Test microsite.get_template return appropriate template.
"""
microsite.set_by_domain(self.microsite.site.domain)
template = microsite.get_template('about.html')
self.assertIn('About this microsite', template.render())
开发者ID:MakeHer,项目名称:edx-platform,代码行数:7,代码来源:test_database.py
示例3: current
def current(cls, *args):
"""
Get the current config model for the provider according to the enabled slugs for this site.
The site configuration expects the value of THIRD_PARTY_AUTH_ENABLED_PROVIDERS to be a dict
of backend_name and the slug being used for the configuration object.
E.g.
"THIRD_PARTY_AUTH_ENABLED_PROVIDERS":{
"google-oauth2":"my-slug-for-this-provider"
}
"""
enabled_providers = microsite.get_value('THIRD_PARTY_AUTH_ENABLED_PROVIDERS', {})
# In a very specific case, azuread-oauth2 does not have a microsite context.
if not microsite.is_request_in_microsite():
try:
microsite.set_by_domain(get_current_request().site.domain)
enabled_providers = microsite.get_value('THIRD_PARTY_AUTH_ENABLED_PROVIDERS', {})
microsite.clear()
except Exception: # pylint: disable=broad-except
pass
if not enabled_providers:
return super(OAuth2ProviderConfig, cls).current(*args)
provider_slug = enabled_providers.get(args[0])
if provider_slug:
return super(OAuth2ProviderConfig, cls).current(provider_slug)
return super(OAuth2ProviderConfig, cls).current(None)
开发者ID:eduNEXT,项目名称:edunext-platform,代码行数:27,代码来源:models.py
示例4: test_get_all_configs
def test_get_all_configs(self):
"""
Tests microsite.get_all_config works as expected.
"""
microsite.set_by_domain(self.microsite.site.domain)
configs = microsite.get_all_config()
self.assertEqual(len(list(configs.keys())), 1)
self.assertEqual(configs[self.microsite.key], self.microsite.values)
开发者ID:cpennington,项目名称:edx-platform,代码行数:8,代码来源:test_database.py
示例5: test_microsite_get_template_when_no_template_exists
def test_microsite_get_template_when_no_template_exists(self):
"""
Test microsite.get_template return None if there is not template in DB.
"""
MicrositeTemplate.objects.all().delete()
microsite.set_by_domain(self.microsite.site.domain)
template = microsite.get_template('about.html')
self.assertIsNone(template)
开发者ID:MakeHer,项目名称:edx-platform,代码行数:8,代码来源:test_database.py
示例6: test_set_config_by_domain
def test_set_config_by_domain(self):
"""
Tests microsite.set_config_by_domain works as expected.
"""
microsite.clear()
# if microsite config does not exist default config should be used
microsite.set_by_domain('unknown')
self.assertEqual(microsite.get_value('university'), 'default_university')
开发者ID:Endika,项目名称:edx-platform,代码行数:8,代码来源:test_filebased.py
示例7: test_get_all_orgs
def test_get_all_orgs(self):
"""
Tests microsite.get_all_orgs works as expected.
"""
microsite.set_by_domain(self.microsite.site.domain)
self.assertEqual(
microsite.get_all_orgs(),
set(self.microsite.get_organizations())
)
开发者ID:MakeHer,项目名称:edx-platform,代码行数:9,代码来源:test_database.py
示例8: test_get_value_for_org
def test_get_value_for_org(self):
"""
Tests microsite.get_value_for_org works as expected.
"""
microsite.set_by_domain(self.microsite.site.domain)
self.assertEqual(
microsite.get_value_for_org(self.microsite.get_organizations()[0], 'platform_name'),
self.microsite.values['platform_name']
)
开发者ID:MakeHer,项目名称:edx-platform,代码行数:9,代码来源:test_database.py
示例9: inner
def inner(request, *args, **kwargs):
"""
Execute the function after setting up the microsite.
"""
try:
microsite.set_by_domain(domain)
return func(request, *args, **kwargs)
finally:
microsite.clear()
开发者ID:mitocw,项目名称:edx-platform,代码行数:9,代码来源:test_api.py
示例10: test_clear
def test_clear(self):
"""
Tests microsite.clear works as expected.
"""
microsite.set_by_domain(self.microsite_subdomain)
self.assertEqual(
microsite.get_value('platform_name'),
'Test Microsite'
)
microsite.clear()
self.assertIsNone(microsite.get_value('platform_name'))
开发者ID:Endika,项目名称:edx-platform,代码行数:11,代码来源:test_filebased.py
示例11: process_request
def process_request(self, request):
"""
Middleware entry point on every request processing. This will associate a request's domain name
with a 'University' and any corresponding microsite configuration information
"""
microsite.clear()
domain = request.META.get('HTTP_HOST', None)
microsite.set_by_domain(domain)
return None
开发者ID:AlexxNica,项目名称:edx-platform,代码行数:12,代码来源:middleware.py
示例12: test_get_value_for_org
def test_get_value_for_org(self):
"""
Tests microsite.get_value_for_org works as expected.
"""
microsite.set_by_domain(self.microsite_subdomain)
self.assertEqual(
microsite.get_value_for_org('TestMicrositeX', 'platform_name'),
'Test Microsite'
)
# if no config is set
microsite.clear()
with patch('django.conf.settings.MICROSITE_CONFIGURATION', False):
self.assertEqual(
microsite.get_value_for_org('TestMicrositeX', 'platform_name', 'Default Value'),
'Default Value'
)
开发者ID:Endika,项目名称:edx-platform,代码行数:17,代码来源:test_filebased.py
示例13: test_get_all_orgs
def test_get_all_orgs(self):
"""
Tests microsite.get_all_orgs works as expected.
"""
microsite.set_by_domain(self.microsite_subdomain)
self.assertEqual(
microsite.get_all_orgs(),
set(['TestMicrositeX', 'LogistrationX'])
)
# if no config is set
microsite.clear()
with patch('django.conf.settings.MICROSITE_CONFIGURATION', False):
self.assertEqual(
microsite.get_all_orgs(),
set()
)
开发者ID:Endika,项目名称:edx-platform,代码行数:17,代码来源:test_filebased.py
示例14: test_get_template_path
def test_get_template_path(self):
"""
Tests get template path works for both relative and absolute paths.
"""
microsite.set_by_domain(self.microsite_subdomain)
CourseEnrollmentFactory(
course_id=self.course.id,
user=self.user
)
response = self.client.get(
reverse('syllabus', args=[unicode(self.course.id)]),
HTTP_HOST=settings.MICROSITE_TEST_HOSTNAME,
)
self.assertContains(response, "Microsite relative path template contents")
self.assertContains(response, "Microsite absolute path template contents")
开发者ID:Endika,项目名称:edx-platform,代码行数:17,代码来源:test_filebased.py
示例15: test_set_config_by_domain
def test_set_config_by_domain(self):
"""
Tests microsite.set_config_by_domain works as expected.
"""
microsite.clear()
# if microsite config does not exist
microsite.set_by_domain('unknown')
self.assertIsNone(microsite.get_value('platform_name'))
# if no microsite exists
Microsite.objects.all().delete()
microsite.clear()
microsite.set_by_domain('unknown')
self.assertIsNone(microsite.get_value('platform_name'))
# if microsite site has no organization it should raise exception
new_microsite = MicrositeFactory.create(key="test_microsite2")
new_microsite.site = SiteFactory.create(domain='test.microsite2.com')
# This would update microsite so we test MicrositeHistory has old microsite
new_microsite.save()
self.assertEqual(MicrositeHistory.objects.all().count(), 2)
with self.assertRaises(Exception):
microsite.set_by_domain('test.microsite2.com')
开发者ID:MakeHer,项目名称:edx-platform,代码行数:23,代码来源:test_database.py
示例16: test_has_override_value
def test_has_override_value(self):
"""
Tests microsite.has_override_value works as expected.
"""
microsite.set_by_domain(self.microsite_subdomain)
self.assertTrue(microsite.has_override_value('platform_name'))
开发者ID:Endika,项目名称:edx-platform,代码行数:6,代码来源:test_filebased.py
示例17: test_is_request_in_microsite
def test_is_request_in_microsite(self):
"""
Tests microsite.is_request_in_microsite works as expected.
"""
microsite.set_by_domain(self.microsite_subdomain)
self.assertTrue(microsite.is_request_in_microsite())
开发者ID:Endika,项目名称:edx-platform,代码行数:6,代码来源:test_filebased.py
示例18: test_get_value
def test_get_value(self):
"""
Tests microsite.get_value works as expected.
"""
microsite.set_by_domain(self.microsite.site.domain)
self.assertEqual(microsite.get_value('email_from_address'), self.microsite.values['email_from_address'])
开发者ID:MakeHer,项目名称:edx-platform,代码行数:6,代码来源:test_database.py
示例19: test_get_value
def test_get_value(self):
"""
Tests microsite.get_value works as expected.
"""
microsite.set_by_domain(self.microsite_subdomain)
self.assertEqual(microsite.get_value('platform_name'), 'Test Site')
开发者ID:cpennington,项目名称:edx-platform,代码行数:6,代码来源:test_filebased.py
示例20: test_get_dict
def test_get_dict(self):
"""
Tests microsite.get_dict works as expected.
"""
microsite.set_by_domain(self.microsite.site.domain)
self.assertEqual(microsite.get_dict('nested_dict'), self.microsite.values['nested_dict'])
开发者ID:MakeHer,项目名称:edx-platform,代码行数:6,代码来源:test_database.py
注:本文中的microsite_configuration.microsite.set_by_domain函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论