Add missing context platform_name and contact_mailing_address. And pass
site configuration to email context.
This commit is contained in:
@@ -21,6 +21,11 @@ def get_base_template_context(site):
|
||||
except NoReverseMatch:
|
||||
dashboard_url = reverse('home')
|
||||
|
||||
if hasattr(site, 'configuration'):
|
||||
site_configuration_values = site.configuration.site_values
|
||||
else:
|
||||
site_configuration_values = {}
|
||||
|
||||
return {
|
||||
# Platform information
|
||||
'homepage_url': marketing_link('ROOT'),
|
||||
@@ -38,4 +43,5 @@ def get_base_template_context(site):
|
||||
'social_media_urls': get_config_value_from_site_or_settings('SOCIAL_MEDIA_FOOTER_URLS', site=site),
|
||||
'mobile_store_urls': get_config_value_from_site_or_settings('MOBILE_STORE_URLS', site=site),
|
||||
'logo_url': get_logo_url_for_email(),
|
||||
'site_configuration_values': site_configuration_values,
|
||||
}
|
||||
|
||||
@@ -175,6 +175,7 @@ class TestCourseUpdateResolver(SchedulesResolverTestMixin, ModuleStoreTestCase):
|
||||
'logo_url': 'https://www.logo.png',
|
||||
'platform_name': '\xe9dX',
|
||||
'show_upsell': False,
|
||||
'site_configuration_values': {},
|
||||
'social_media_urls': {},
|
||||
'template_revision': 'release',
|
||||
'unsubscribe_url': None,
|
||||
@@ -263,6 +264,7 @@ class TestCourseNextSectionUpdateResolver(SchedulesResolverTestMixin, ModuleStor
|
||||
'logo_url': 'https://www.logo.png',
|
||||
'platform_name': '\xe9dX',
|
||||
'show_upsell': False,
|
||||
'site_configuration_values': {},
|
||||
'social_media_urls': {},
|
||||
'template_revision': 'release',
|
||||
'unsubscribe_url': None,
|
||||
|
||||
@@ -29,6 +29,25 @@ def get_current_site_configuration():
|
||||
return None
|
||||
|
||||
|
||||
def get_current_site_configuration_values(default=None):
|
||||
"""
|
||||
Returns `SiteConfiguration.site_values` for current site.
|
||||
Args:
|
||||
default (dict): default value (`{}` if not specified) to return if site configuration is not available.
|
||||
Returns:
|
||||
(dict) Site Configuration value for the current site or default
|
||||
"""
|
||||
if default is None:
|
||||
default = {}
|
||||
|
||||
site_configuration = get_current_site_configuration()
|
||||
|
||||
if site_configuration:
|
||||
return site_configuration.site_values
|
||||
else:
|
||||
return default
|
||||
|
||||
|
||||
def is_site_configuration_enabled():
|
||||
"""
|
||||
Returns True is there is SiteConfiguration instance associated with the current site and it is enabled, otherwise
|
||||
|
||||
@@ -169,3 +169,17 @@ class TestHelpers(TestCase):
|
||||
list(configuration_helpers.get_current_site_orgs()),
|
||||
test_orgs
|
||||
)
|
||||
|
||||
def test_get_current_site_configuration_values(self):
|
||||
"""
|
||||
Test get_current_site_configuration_values helper function
|
||||
"""
|
||||
site_values = configuration_helpers.get_current_site_configuration_values()
|
||||
self.assertTrue(isinstance(site_values, dict))
|
||||
|
||||
# without any site configuration it should return empty dict
|
||||
self.assertEqual(site_values, {})
|
||||
|
||||
with with_site_configuration_context(configuration=test_config):
|
||||
site_values = configuration_helpers.get_current_site_configuration_values()
|
||||
self.assertEqual(site_values, test_config)
|
||||
|
||||
Reference in New Issue
Block a user