Commit 80644e0d by Saleem Latif Committed by GitHub

Merge pull request #13039 from edx/saleem-latif/WL-343

WL-343: Merge microsites into Comprehensive Theming
parents e8c60bc6 8ae92901
......@@ -58,7 +58,6 @@ from course_action_state.managers import CourseActionStateItemNotFoundError
from course_action_state.models import CourseRerunState, CourseRerunUIStateManager
from course_creators.views import get_course_creator_status, add_user_with_status_unrequested
from edxmako.shortcuts import render_to_response
from microsite_configuration import microsite
from models.settings.course_grading import CourseGradingModel
from models.settings.course_metadata import CourseMetadata
from models.settings.encoder import CourseSettingsEncoder
......@@ -69,6 +68,7 @@ from openedx.core.djangoapps.models.course_details import CourseDetails
from openedx.core.djangoapps.programs.models import ProgramsApiConfig
from openedx.core.djangoapps.programs.utils import get_programs
from openedx.core.djangoapps.self_paced.models import SelfPacedConfiguration
from openedx.core.djangoapps.site_configuration import helpers as configuration_helpers
from openedx.core.lib.course_tabs import CourseTabPluginManager
from openedx.core.lib.courses import course_image_url
from openedx.core.djangolib.js_utils import dump_js_escaped_json
......@@ -975,14 +975,14 @@ def settings_handler(request, course_key_string):
if 'text/html' in request.META.get('HTTP_ACCEPT', '') and request.method == 'GET':
upload_asset_url = reverse_course_url('assets_handler', course_key)
# see if the ORG of this course can be attributed to a 'Microsite'. In that case, the
# see if the ORG of this course can be attributed to a defined configuration . In that case, the
# course about page should be editable in Studio
marketing_site_enabled = microsite.get_value_for_org(
marketing_site_enabled = configuration_helpers.get_value_for_org(
course_module.location.org,
'ENABLE_MKTG_SITE',
settings.FEATURES.get('ENABLE_MKTG_SITE', False)
)
enable_extended_course_details = microsite.get_value_for_org(
enable_extended_course_details = configuration_helpers.get_value_for_org(
course_module.location.org,
'ENABLE_EXTENDED_COURSE_DETAILS',
settings.FEATURES.get('ENABLE_EXTENDED_COURSE_DETAILS', False)
......
......@@ -12,7 +12,7 @@ from edxmako.shortcuts import render_to_response
from external_auth.views import (ssl_login_shortcut, ssl_get_cert_from_request,
redirect_with_get)
from microsite_configuration import microsite
from openedx.core.djangoapps.site_configuration import helpers as configuration_helpers
__all__ = ['signup', 'login_page', 'howitworks']
......@@ -61,7 +61,7 @@ def login_page(request):
{
'csrf': csrf_token,
'forgot_password_link': "//{base}/login#forgot-password-modal".format(base=settings.LMS_BASE),
'platform_name': microsite.get_value('platform_name', settings.PLATFORM_NAME),
'platform_name': configuration_helpers.get_value('platform_name', settings.PLATFORM_NAME),
}
)
......
......@@ -223,54 +223,54 @@ FEATURES['EMBARGO'] = True
# set up some testing for microsites
FEATURES['USE_MICROSITES'] = True
MICROSITE_ROOT_DIR = COMMON_ROOT / 'test' / 'test_microsites'
MICROSITE_ROOT_DIR = COMMON_ROOT / 'test' / 'test_sites'
MICROSITE_CONFIGURATION = {
"test_microsite": {
"domain_prefix": "testmicrosite",
"university": "test_microsite",
"platform_name": "Test Microsite",
"logo_image_url": "test_microsite/images/header-logo.png",
"email_from_address": "test_microsite@edx.org",
"payment_support_email": "test_microsite@edx.org",
"test_site": {
"domain_prefix": "test-site",
"university": "test_site",
"platform_name": "Test Site",
"logo_image_url": "test_site/images/header-logo.png",
"email_from_address": "test_site@edx.org",
"payment_support_email": "test_site@edx.org",
"ENABLE_MKTG_SITE": False,
"SITE_NAME": "test_microsite.localhost",
"course_org_filter": "TestMicrositeX",
"SITE_NAME": "test_site.localhost",
"course_org_filter": "TestSiteX",
"course_about_show_social_links": False,
"css_overrides_file": "test_microsite/css/test_microsite.css",
"css_overrides_file": "test_site/css/test_site.css",
"show_partners": False,
"show_homepage_promo_video": False,
"course_index_overlay_text": "This is a Test Microsite Overlay Text.",
"course_index_overlay_logo_file": "test_microsite/images/header-logo.png",
"homepage_overlay_html": "<h1>This is a Test Microsite Overlay HTML</h1>",
"course_index_overlay_text": "This is a Test Site Overlay Text.",
"course_index_overlay_logo_file": "test_site/images/header-logo.png",
"homepage_overlay_html": "<h1>This is a Test Site Overlay HTML</h1>",
"ALWAYS_REDIRECT_HOMEPAGE_TO_DASHBOARD_FOR_AUTHENTICATED_USER": False,
"COURSE_CATALOG_VISIBILITY_PERMISSION": "see_in_catalog",
"COURSE_ABOUT_VISIBILITY_PERMISSION": "see_about_page",
"ENABLE_SHOPPING_CART": True,
"ENABLE_PAID_COURSE_REGISTRATION": True,
"SESSION_COOKIE_DOMAIN": "test_microsite.localhost",
"SESSION_COOKIE_DOMAIN": "test_site.localhost",
"urls": {
'ABOUT': 'testmicrosite/about',
'PRIVACY': 'testmicrosite/privacy',
'TOS_AND_HONOR': 'testmicrosite/tos-and-honor',
'ABOUT': 'test-site/about',
'PRIVACY': 'test-site/privacy',
'TOS_AND_HONOR': 'test-site/tos-and-honor',
},
},
"microsite_with_logistration": {
"site_with_logistration": {
"domain_prefix": "logistration",
"university": "logistration",
"platform_name": "Test logistration",
"logo_image_url": "test_microsite/images/header-logo.png",
"email_from_address": "test_microsite@edx.org",
"payment_support_email": "test_microsite@edx.org",
"logo_image_url": "test_site/images/header-logo.png",
"email_from_address": "test_site@edx.org",
"payment_support_email": "test_site@edx.org",
"ENABLE_MKTG_SITE": False,
"ENABLE_COMBINED_LOGIN_REGISTRATION": True,
"SITE_NAME": "test_microsite.localhost",
"SITE_NAME": "test_site.localhost",
"course_org_filter": "LogistrationX",
"course_about_show_social_links": False,
"css_overrides_file": "test_microsite/css/test_microsite.css",
"css_overrides_file": "test_site/css/test_site.css",
"show_partners": False,
"show_homepage_promo_video": False,
"course_index_overlay_text": "Logistration.",
"course_index_overlay_logo_file": "test_microsite/images/header-logo.png",
"course_index_overlay_logo_file": "test_site/images/header-logo.png",
"homepage_overlay_html": "<h1>This is a Logistration HTML</h1>",
"ALWAYS_REDIRECT_HOMEPAGE_TO_DASHBOARD_FOR_AUTHENTICATED_USER": False,
"COURSE_CATALOG_VISIBILITY_PERMISSION": "see_in_catalog",
......@@ -284,7 +284,7 @@ MICROSITE_CONFIGURATION = {
"domain_prefix": "www",
}
}
MICROSITE_TEST_HOSTNAME = 'testmicrosite.testserver'
MICROSITE_TEST_HOSTNAME = 'test-site.testserver'
MICROSITE_LOGISTRATION_HOSTNAME = 'logistration.testserver'
TEST_THEME = COMMON_ROOT / "test" / "test-theme"
......
......@@ -17,13 +17,13 @@ import logging
from django.http import HttpResponse
from django.template import Context
from microsite_configuration import microsite
from edxmako import lookup_template
from edxmako.request_context import get_template_request_context
from django.conf import settings
from django.core.urlresolvers import reverse
from openedx.core.djangoapps.theming.helpers import get_template_path
from openedx.core.djangoapps.theming.helpers import get_template_path, is_request_in_themed_site
from openedx.core.djangoapps.site_configuration import helpers as configuration_helpers
log = logging.getLogger(__name__)
......@@ -38,7 +38,7 @@ def marketing_link(name):
# link_map maps URLs from the marketing site to the old equivalent on
# the Django site
link_map = settings.MKTG_URL_LINK_MAP
enable_mktg_site = microsite.get_value(
enable_mktg_site = configuration_helpers.get_value(
'ENABLE_MKTG_SITE',
settings.FEATURES.get('ENABLE_MKTG_SITE', False)
)
......@@ -71,7 +71,7 @@ def is_marketing_link_set(name):
Returns a boolean if a given named marketing link is configured.
"""
enable_mktg_site = microsite.get_value(
enable_mktg_site = configuration_helpers.get_value(
'ENABLE_MKTG_SITE',
settings.FEATURES.get('ENABLE_MKTG_SITE', False)
)
......@@ -102,13 +102,13 @@ def marketing_link_context_processor(request):
)
def microsite_footer_context_processor(request):
def footer_context_processor(request): # pylint: disable=unused-argument
"""
Checks the site name to determine whether to use the edX.org footer or the Open Source Footer.
"""
return dict(
[
("IS_REQUEST_IN_MICROSITE", microsite.is_request_in_microsite())
("IS_REQUEST_IN_MICROSITE", is_request_in_themed_site())
]
)
......
......@@ -11,7 +11,6 @@ from microsite_configuration import settings
from django.conf import settings as base_settings
from microsite_configuration import microsite
from .templatetags.microsite import page_title_breadcrumbs
class MicrositeAwareSettings(object):
......
""" Django template ontext processors. """
from django.conf import settings
from microsite_configuration import microsite
def microsite_context(request): # pylint: disable=missing-docstring,unused-argument
return {
'platform_name': microsite.get_value('platform_name', settings.PLATFORM_NAME)
}
......@@ -30,7 +30,7 @@ class FilebasedMicrositeBackendTests(TestCase):
"""
def setUp(self):
super(FilebasedMicrositeBackendTests, self).setUp()
self.microsite_subdomain = 'testmicrosite'
self.microsite_subdomain = 'test-site'
def tearDown(self):
super(FilebasedMicrositeBackendTests, self).tearDown()
......@@ -41,7 +41,7 @@ class FilebasedMicrositeBackendTests(TestCase):
Tests microsite.get_value works as expected.
"""
microsite.set_by_domain(self.microsite_subdomain)
self.assertEqual(microsite.get_value('platform_name'), 'Test Microsite')
self.assertEqual(microsite.get_value('platform_name'), 'Test Site')
def test_is_request_in_microsite(self):
"""
......@@ -63,15 +63,15 @@ class FilebasedMicrositeBackendTests(TestCase):
"""
microsite.set_by_domain(self.microsite_subdomain)
self.assertEqual(
microsite.get_value_for_org('TestMicrositeX', 'platform_name'),
'Test Microsite'
microsite.get_value_for_org('TestSiteX', 'platform_name'),
'Test Site'
)
# 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'),
microsite.get_value_for_org('TestSiteX', 'platform_name', 'Default Value'),
'Default Value'
)
......@@ -82,7 +82,7 @@ class FilebasedMicrositeBackendTests(TestCase):
microsite.set_by_domain(self.microsite_subdomain)
self.assertEqual(
microsite.get_all_orgs(),
set(['TestMicrositeX', 'LogistrationX'])
set(['TestSiteX', 'LogistrationX'])
)
# if no config is set
......@@ -100,7 +100,7 @@ class FilebasedMicrositeBackendTests(TestCase):
microsite.set_by_domain(self.microsite_subdomain)
self.assertEqual(
microsite.get_value('platform_name'),
'Test Microsite'
'Test Site'
)
microsite.clear()
self.assertIsNone(microsite.get_value('platform_name'))
......@@ -145,7 +145,7 @@ class FilebasedMicrositeTemplateBackendTests(ModuleStoreTestCase):
"""
def setUp(self):
super(FilebasedMicrositeTemplateBackendTests, self).setUp()
self.microsite_subdomain = 'testmicrosite'
self.microsite_subdomain = 'test-site'
self.course = CourseFactory.create()
self.user = UserFactory.create(username="Bob", email="bob@example.com", password="edx")
self.client.login(username=self.user.username, password="edx")
......
......@@ -21,7 +21,7 @@ class SiteFactory(DjangoModelFactory):
model = Site
name = "test microsite"
domain = "testmicrosite.testserver"
domain = "test-site.testserver"
class MicrositeFactory(DjangoModelFactory):
......@@ -31,31 +31,31 @@ class MicrositeFactory(DjangoModelFactory):
class Meta(object):
model = Microsite
key = "test_microsite"
key = "test_site"
site = factory.SubFactory(SiteFactory)
values = {
"domain_prefix": "testmicrosite",
"university": "test_microsite",
"platform_name": "Test Microsite DB",
"logo_image_url": "test_microsite/images/header-logo.png",
"email_from_address": "test_microsite_db@edx.org",
"payment_support_email": "test_microsit_dbe@edx.org",
"domain_prefix": "test-site",
"university": "test_site",
"platform_name": "Test Site DB",
"logo_image_url": "test_site/images/header-logo.png",
"email_from_address": "test_site@edx.org",
"payment_support_email": "test_site_dbe@edx.org",
"ENABLE_MKTG_SITE": False,
"SITE_NAME": "test_microsite.localhost",
"course_org_filter": "TestMicrositeX",
"SITE_NAME": "test_site.localhost",
"course_org_filter": "TestSiteX",
"course_about_show_social_links": False,
"css_overrides_file": "test_microsite/css/test_microsite.css",
"css_overrides_file": "test_site/css/test_site.css",
"show_partners": False,
"show_homepage_promo_video": False,
"course_index_overlay_text": "This is a Test Microsite Overlay Text.",
"course_index_overlay_logo_file": "test_microsite/images/header-logo.png",
"homepage_overlay_html": "<h1>This is a Test Microsite Overlay HTML</h1>",
"course_index_overlay_text": "This is a Test Site Overlay Text.",
"course_index_overlay_logo_file": "test_site/images/header-logo.png",
"homepage_overlay_html": "<h1>This is a Test Site Overlay HTML</h1>",
"ALWAYS_REDIRECT_HOMEPAGE_TO_DASHBOARD_FOR_AUTHENTICATED_USER": False,
"COURSE_CATALOG_VISIBILITY_PERMISSION": "see_in_catalog",
"COURSE_ABOUT_VISIBILITY_PERMISSION": "see_about_page",
"ENABLE_SHOPPING_CART": True,
"ENABLE_PAID_COURSE_REGISTRATION": True,
"SESSION_COOKIE_DOMAIN": "test_microsite.localhost",
"SESSION_COOKIE_DOMAIN": "test_site.localhost",
"nested_dict": {
"key 1": "value 1",
"key 2": "value 2",
......
......@@ -35,8 +35,8 @@ class MicrositeAdminTests(DatabaseMicrositeTestCase):
Tests save action for Microsite model form.
"""
new_values = {
"domain_prefix": "testmicrosite_new",
"platform_name": "Test Microsite New"
"domain_prefix": "test-site-new",
"platform_name": "Test Site New"
}
microsite_form = self.microsite_admin.get_form(self.request)(instance=self.microsite, data={
"key": self.microsite.key,
......
""" Tests for Django template context processors. """
from django.test import TestCase
from django.test.client import RequestFactory
from django.test.utils import override_settings
from microsite_configuration.context_processors import microsite_context
PLATFORM_NAME = 'Test Platform'
@override_settings(PLATFORM_NAME=PLATFORM_NAME)
class MicrositeContextProcessorTests(TestCase):
""" Tests for the microsite context processor. """
def setUp(self):
super(MicrositeContextProcessorTests, self).setUp()
request = RequestFactory().get('/')
self.context = microsite_context(request)
def test_platform_name(self):
""" Verify the context includes the platform name. """
self.assertEqual(self.context['platform_name'], PLATFORM_NAME)
......@@ -42,5 +42,5 @@ class TestMicrosites(DatabaseMicrositeTestCase):
"""
with patch('microsite_configuration.microsite.BACKEND',
get_backend(site_backend, BaseMicrositeBackend)):
value = get_value_for_org("TestMicrositeX", "university", "default_value")
self.assertEquals(value, "test_microsite")
value = get_value_for_org("TestSiteX", "university", "default_value")
self.assertEquals(value, "test_site")
# -*- coding: utf-8 -*-
"""
Tests microsite_configuration templatetags and helper functions.
Tests configuration templatetags and helper functions.
"""
import logging
from mock import patch
from django.test import TestCase
from django.conf import settings
from microsite_configuration.templatetags import microsite as microsite_tags
from microsite_configuration import microsite
from microsite_configuration.backends.base import BaseMicrositeBackend
from microsite_configuration.backends.database import DatabaseMicrositeBackend
from openedx.core.djangoapps.site_configuration.templatetags import configuration as configuration_tags
from openedx.core.djangoapps.site_configuration import helpers as configuration_helpers
log = logging.getLogger(__name__)
......@@ -22,30 +23,30 @@ class MicrositeTests(TestCase):
def test_breadcrumbs(self):
crumbs = ['my', 'less specific', 'Page']
expected = u'my | less specific | Page | edX'
title = microsite_tags.page_title_breadcrumbs(*crumbs)
title = configuration_helpers.page_title_breadcrumbs(*crumbs)
self.assertEqual(expected, title)
def test_unicode_title(self):
crumbs = [u'øo', u'π tastes gréât', u'驴']
expected = u'øo | π tastes gréât | 驴 | edX'
title = microsite_tags.page_title_breadcrumbs(*crumbs)
title = configuration_helpers.page_title_breadcrumbs(*crumbs)
self.assertEqual(expected, title)
def test_platform_name(self):
pname = microsite_tags.platform_name()
pname = configuration_tags.platform_name()
self.assertEqual(pname, settings.PLATFORM_NAME)
def test_breadcrumb_tag(self):
crumbs = ['my', 'less specific', 'Page']
expected = u'my | less specific | Page | edX'
title = microsite_tags.page_title_breadcrumbs_tag(None, *crumbs)
title = configuration_tags.page_title_breadcrumbs_tag(None, *crumbs)
self.assertEqual(expected, title)
def test_microsite_template_path(self):
"""
When an unexistent path is passed to the filter, it should return the same path
"""
path = microsite_tags.microsite_template_path('footer.html')
path = configuration_tags.microsite_template_path('footer.html')
self.assertEqual("footer.html", path)
def test_get_backend_raise_error_for_invalid_class(self):
......
......@@ -51,7 +51,7 @@ class MicrositeSessionCookieTests(DatabaseMicrositeTestCase):
with patch('microsite_configuration.microsite.BACKEND',
get_backend(site_backend, BaseMicrositeBackend)):
response = self.client.get('/')
self.assertNotIn('test_microsite.localhost', str(response.cookies['sessionid']))
self.assertNotIn('test_site.localhost', str(response.cookies['sessionid']))
self.assertNotIn('Domain', str(response.cookies['sessionid']))
@ddt.data(*MICROSITE_BACKENDS)
......@@ -63,7 +63,7 @@ class MicrositeSessionCookieTests(DatabaseMicrositeTestCase):
with patch('microsite_configuration.microsite.BACKEND',
get_backend(site_backend, BaseMicrositeBackend)):
response = self.client.get('/', HTTP_HOST=settings.MICROSITE_TEST_HOSTNAME)
self.assertIn('test_microsite.localhost', str(response.cookies['sessionid']))
self.assertIn('test_site.localhost', str(response.cookies['sessionid']))
@ddt.data(*MICROSITE_BACKENDS)
def test_microsite_none_cookie_domain(self, site_backend):
......@@ -77,5 +77,5 @@ class MicrositeSessionCookieTests(DatabaseMicrositeTestCase):
with patch('microsite_configuration.microsite.BACKEND',
get_backend(site_backend, BaseMicrositeBackend)):
response = self.client.get('/', HTTP_HOST=settings.MICROSITE_TEST_HOSTNAME)
self.assertNotIn('test_microsite.localhost', str(response.cookies['sessionid']))
self.assertNotIn('test_site.localhost', str(response.cookies['sessionid']))
self.assertNotIn('Domain', str(response.cookies['sessionid']))
......@@ -22,7 +22,7 @@ class DatabaseMicrositeTestCase(TestCase):
def setUp(self):
super(DatabaseMicrositeTestCase, self).setUp()
self.microsite = MicrositeFactory.create()
MicrositeOrganizationMappingFactory.create(microsite=self.microsite, organization='TestMicrositeX')
MicrositeOrganizationMappingFactory.create(microsite=self.microsite, organization='TestSiteX')
def side_effect_for_get_value(value, return_value):
......
......@@ -6,9 +6,12 @@ from django.utils.translation import get_language_bidi
from mako.exceptions import TemplateLookupException
from openedx.core.djangolib.js_utils import js_escaped_string
from openedx.core.djangoapps.theming.helpers import (
get_page_title_breadcrumbs,
from openedx.core.djangoapps.site_configuration.helpers import (
page_title_breadcrumbs,
get_value,
)
from openedx.core.djangoapps.theming.helpers import (
get_template_path,
get_themed_template_path,
is_request_in_themed_site,
......@@ -138,7 +141,7 @@ else:
<%def name="get_page_title_breadcrumbs(*args)"><%
return get_page_title_breadcrumbs(*args)
return page_title_breadcrumbs(*args)
%></%def>
<%def name="get_platform_name()"><%
......
......@@ -17,10 +17,9 @@ from django.utils.translation import ugettext_lazy as _
from django.template import loader
from django.conf import settings
from microsite_configuration import microsite
from student.models import CourseEnrollmentAllowed
from util.password_policy_validators import validate_password_strength
from openedx.core.djangoapps.theming import helpers as theming_helpers
from openedx.core.djangoapps.site_configuration import helpers as configuration_helpers
class PasswordResetFormNoActive(PasswordResetForm):
......@@ -54,7 +53,7 @@ class PasswordResetFormNoActive(PasswordResetForm):
email_template_name='registration/password_reset_email.html',
use_https=False,
token_generator=default_token_generator,
from_email=theming_helpers.get_value('email_from_address', settings.DEFAULT_FROM_EMAIL),
from_email=configuration_helpers.get_value('email_from_address', settings.DEFAULT_FROM_EMAIL),
request=None
):
"""
......@@ -66,7 +65,7 @@ class PasswordResetFormNoActive(PasswordResetForm):
from django.core.mail import send_mail
for user in self.users_cache:
if not domain_override:
site_name = microsite.get_value(
site_name = configuration_helpers.get_value(
'SITE_NAME',
settings.SITE_NAME
)
......@@ -79,7 +78,7 @@ class PasswordResetFormNoActive(PasswordResetForm):
'user': user,
'token': token_generator.make_token(user),
'protocol': 'https' if use_https else 'http',
'platform_name': microsite.get_value('platform_name', settings.PLATFORM_NAME)
'platform_name': configuration_helpers.get_value('platform_name', settings.PLATFORM_NAME)
}
subject = loader.render_to_string(subject_template_name, context)
# Email subject *must not* contain newlines
......
......@@ -51,10 +51,10 @@ from lms.djangoapps.badges.utils import badges_enabled
from certificates.models import GeneratedCertificate
from course_modes.models import CourseMode
from enrollment.api import _default_course_mode
from microsite_configuration import microsite
import lms.lib.comment_client as cc
from openedx.core.djangoapps.commerce.utils import ecommerce_api_client, ECOMMERCE_DATE_FORMAT
from openedx.core.djangoapps.content.course_overviews.models import CourseOverview
from openedx.core.djangoapps.site_configuration import helpers as configuration_helpers
from util.model_utils import emit_field_changed_events, get_changed_fields_dict
from util.query import use_read_replica_if_available
from util.milestones_helpers import is_entrance_exams_enabled
......@@ -1950,7 +1950,7 @@ class LinkedInAddToProfileConfiguration(ConfigurationModel):
target (str): An identifier for the occurrance of the button.
"""
company_identifier = microsite.get_value('LINKEDIN_COMPANY_ID', self.company_identifier)
company_identifier = configuration_helpers.get_value('LINKEDIN_COMPANY_ID', self.company_identifier)
params = OrderedDict([
('_ed', company_identifier),
('pfCertificationName', self._cert_name(course_name, cert_mode).encode('utf-8')),
......@@ -1972,7 +1972,7 @@ class LinkedInAddToProfileConfiguration(ConfigurationModel):
cert_mode,
_(u"{platform_name} Certificate for {course_name}")
).format(
platform_name=microsite.get_value('platform_name', settings.PLATFORM_NAME),
platform_name=configuration_helpers.get_value('platform_name', settings.PLATFORM_NAME),
course_name=course_name
)
......
......@@ -23,13 +23,6 @@ from student.models import LinkedInAddToProfileConfiguration
# pylint: disable=no-member
def _fake_is_request_in_microsite():
"""
Mocked version of microsite helper method to always return true
"""
return True
class CertificateDisplayTestBase(SharedModuleStoreTestCase):
"""Tests display of certificates on the student dashboard. """
......@@ -163,10 +156,10 @@ class CertificateDisplayTest(CertificateDisplayTestBase):
# now we should see it
self._check_linkedin_visibility(True)
@mock.patch("microsite_configuration.microsite.is_request_in_microsite", _fake_is_request_in_microsite)
def test_post_to_linkedin_microsite(self):
@mock.patch("openedx.core.djangoapps.theming.helpers.is_request_in_themed_site", mock.Mock(return_value=True))
def test_post_to_linkedin_site_specific(self):
"""
Verifies behavior for microsites which disables the post to LinkedIn
Verifies behavior for themed sites which disables the post to LinkedIn
feature (for now)
"""
self._create_certificate('honor')
......@@ -177,7 +170,7 @@ class CertificateDisplayTest(CertificateDisplayTestBase):
)
config.save()
# now we should not see it because we are in a microsite
# now we should not see it because we are in a themed site
self._check_linkedin_visibility(False)
......
"""
Test for User Creation from Micro-Sites
Test for user creation from sites with configuration overrides.
"""
from django.test import TestCase
from student.models import UserSignupSource
......@@ -8,7 +8,7 @@ import json
from django.core.urlresolvers import reverse
from django.contrib.auth.models import User
FAKE_MICROSITE = {
FAKE_SITE = {
"SITE_NAME": "openedx.localhost",
"university": "fakeuniversity",
"course_org_filter": "fakeorg",
......@@ -30,7 +30,7 @@ FAKE_MICROSITE = {
def fake_site_name(name, default=None):
"""
create a fake microsite site name
Method for getting site name for a fake site.
"""
if name == 'SITE_NAME':
return 'openedx.localhost'
......@@ -38,17 +38,17 @@ def fake_site_name(name, default=None):
return default
def fake_microsite_get_value(name, default=None):
def fake_get_value(name, default=None):
"""
create a fake microsite site name
Method for getting configuration override values for a fake site.
"""
return FAKE_MICROSITE.get(name, default)
return FAKE_SITE.get(name, default)
class TestMicrosite(TestCase):
"""Test for Account Creation from a white labeled Micro-Sites"""
class TestSite(TestCase):
"""Test for Account Creation from white labeled Sites"""
def setUp(self):
super(TestMicrosite, self).setUp()
super(TestSite, self).setUp()
self.username = "test_user"
self.url = reverse("create_account")
self.params = {
......@@ -68,39 +68,39 @@ class TestMicrosite(TestCase):
"title": "foo"
}.items())
@mock.patch("microsite_configuration.microsite.get_value", fake_site_name)
@mock.patch("openedx.core.djangoapps.site_configuration.helpers.get_value", fake_site_name)
def test_user_signup_source(self):
"""
test to create a user form the microsite and see that it record has been
saved in the UserSignupSource Table
Test to create a user from a site with configuration overrides and see that its record has been
saved in the UserSignupSource Table.
"""
response = self.client.post(self.url, self.params)
self.assertEqual(response.status_code, 200)
self.assertGreater(len(UserSignupSource.objects.filter(site='openedx.localhost')), 0)
def test_user_signup_from_non_micro_site(self):
def test_user_signup_from_non_configured_site(self):
"""
test to create a user form the non-microsite. The record should not be saved
in the UserSignupSource Table
Test to create a user from a site without any configuration override. The record should not be saved
in UserSignupSource Table.
"""
response = self.client.post(self.url, self.params)
self.assertEqual(response.status_code, 200)
self.assertEqual(len(UserSignupSource.objects.filter(site='openedx.localhost')), 0)
@mock.patch("microsite_configuration.microsite.get_value", fake_microsite_get_value)
@mock.patch("openedx.core.djangoapps.site_configuration.helpers.get_value", fake_get_value)
def test_user_signup_missing_enhanced_profile(self):
"""
test to create a user form the microsite but don't provide any of the microsite specific
profile information
Test to create a user from a site with configuration overrides but don't provide any overrides for
profile information.
"""
response = self.client.post(self.url, self.params)
self.assertEqual(response.status_code, 400)
@mock.patch("microsite_configuration.microsite.get_value", fake_microsite_get_value)
@mock.patch("openedx.core.djangoapps.site_configuration.helpers.get_value", fake_get_value)
def test_user_signup_including_enhanced_profile(self):
"""
test to create a user form the microsite but don't provide any of the microsite specific
profile information
Test to create a user from a site with configuration overrides with overrides for
profile information.
"""
response = self.client.post(self.url, self.extended_params)
self.assertEqual(response.status_code, 200)
......
......@@ -20,7 +20,7 @@ from django.conf import settings
from edxmako.shortcuts import render_to_string
from util.request import safe_get_host
from util.testing import EventTestMixin
from openedx.core.djangoapps.theming import helpers as theming_helpers
from openedx.core.djangoapps.site_configuration import helpers as configuration_helpers
from openedx.core.djangoapps.theming.tests.test_util import with_comprehensive_theme
......@@ -57,7 +57,7 @@ class EmailTestMixin(object):
email_user.assert_called_with(
mock_render_to_string(subject_template, subject_context),
mock_render_to_string(body_template, body_context),
theming_helpers.get_value('email_from_address', settings.DEFAULT_FROM_EMAIL)
configuration_helpers.get_value('email_from_address', settings.DEFAULT_FROM_EMAIL)
)
def append_allowed_hosts(self, hostname):
......@@ -298,7 +298,7 @@ class EmailChangeRequestTests(EventTestMixin, TestCase):
send_mail.assert_called_with(
mock_render_to_string('emails/email_change_subject.txt', context),
mock_render_to_string('emails/email_change.txt', context),
theming_helpers.get_value('email_from_address', settings.DEFAULT_FROM_EMAIL),
configuration_helpers.get_value('email_from_address', settings.DEFAULT_FROM_EMAIL),
[new_email]
)
self.assert_event_emitted(
......
......@@ -25,8 +25,8 @@ from student.tests.factories import UserFactory
from student.tests.test_email import mock_render_to_string
from util.testing import EventTestMixin
from .test_microsite import fake_microsite_get_value
from openedx.core.djangoapps.theming import helpers as theming_helpers
from .test_configuration_overrides import fake_get_value
from openedx.core.djangoapps.site_configuration import helpers as configuration_helpers
@unittest.skipUnless(
......@@ -125,7 +125,7 @@ class ResetPasswordTests(EventTestMixin, CacheIsolationTestCase):
(subject, msg, from_addr, to_addrs) = send_email.call_args[0]
self.assertIn("Password reset", subject)
self.assertIn("You're receiving this e-mail because you requested a password reset", msg)
self.assertEquals(from_addr, theming_helpers.get_value('email_from_address', settings.DEFAULT_FROM_EMAIL))
self.assertEquals(from_addr, configuration_helpers.get_value('email_from_address', settings.DEFAULT_FROM_EMAIL))
self.assertEquals(len(to_addrs), 1)
self.assertIn(self.user.email, to_addrs)
......@@ -195,9 +195,9 @@ class ResetPasswordTests(EventTestMixin, CacheIsolationTestCase):
)
@unittest.skipUnless(settings.ROOT_URLCONF == 'lms.urls', "Test only valid in LMS")
@patch("microsite_configuration.microsite.get_value", fake_microsite_get_value)
@patch("openedx.core.djangoapps.site_configuration.helpers.get_value", fake_get_value)
@patch('django.core.mail.send_mail')
def test_reset_password_email_microsite(self, send_email):
def test_reset_password_email_configuration_override(self, send_email):
"""
Tests that the right url domain and platform name is included in
the reset password email
......@@ -254,9 +254,9 @@ class ResetPasswordTests(EventTestMixin, CacheIsolationTestCase):
self.assertTrue(self.user.is_active)
@patch('student.views.password_reset_confirm')
@patch("microsite_configuration.microsite.get_value", fake_microsite_get_value)
def test_reset_password_good_token_microsite(self, reset_confirm):
"""Tests password reset confirmation page for micro site"""
@patch("openedx.core.djangoapps.site_configuration.helpers.get_value", fake_get_value)
def test_reset_password_good_token_configuration_override(self, reset_confirm):
"""Tests password reset confirmation page for site configuration override."""
url = reverse(
"password_reset_confirm",
kwargs={"uidb36": self.uidb36, "token": self.token}
......
"""Third party authentication. """
from microsite_configuration import microsite
from openedx.core.djangoapps.site_configuration import helpers as configuration_helpers
def is_enabled():
......@@ -9,7 +9,7 @@ def is_enabled():
# We do this import internally to avoid initializing settings prematurely
from django.conf import settings
return microsite.get_value(
return configuration_helpers.get_value(
"ENABLE_THIRD_PARTY_AUTH",
settings.FEATURES.get("ENABLE_THIRD_PARTY_AUTH")
)
......@@ -21,7 +21,7 @@ from social.backends.saml import SAMLAuth, SAMLIdentityProvider
from .lti import LTIAuthBackend, LTI_PARAMS_KEY
from social.exceptions import SocialAuthBaseException
from social.utils import module_member
from openedx.core.djangoapps.theming.helpers import get_value as get_themed_value
from openedx.core.djangoapps.site_configuration import helpers as configuration_helpers
log = logging.getLogger(__name__)
......@@ -454,7 +454,9 @@ class SAMLConfiguration(ConfigurationModel):
other_config = json.loads(self.other_config_str)
if name in ("TECHNICAL_CONTACT", "SUPPORT_CONTACT"):
contact = {
"givenName": "{} Support".format(get_themed_value('PLATFORM_NAME', settings.PLATFORM_NAME)),
"givenName": "{} Support".format(
configuration_helpers.get_value('PLATFORM_NAME', settings.PLATFORM_NAME),
),
"emailAddress": settings.TECH_SUPPORT_EMAIL
}
contact.update(other_config.get(name, {}))
......
......@@ -3,9 +3,9 @@ import re
from django.conf import settings
from microsite_configuration import microsite
from opaque_keys import InvalidKeyError
from opaque_keys.edx.locations import SlashSeparatedCourseKey
from openedx.core.djangoapps.site_configuration import helpers as configuration_helpers
# accommodates course api urls, excluding any course api routes that do not fall under v*/courses, such as v1/blocks.
COURSE_REGEX = re.compile(r'^(.*?/courses/)(?!v[0-9]+/[^/]+){}'.format(settings.COURSE_ID_PATTERN))
......@@ -23,7 +23,7 @@ def safe_get_host(request):
if isinstance(settings.ALLOWED_HOSTS, (list, tuple)) and '*' not in settings.ALLOWED_HOSTS:
return request.get_host()
else:
return microsite.get_value('site_domain', settings.SITE_NAME)
return configuration_helpers.get_value('site_domain', settings.SITE_NAME)
def course_id_from_url(url):
......
......@@ -11,7 +11,7 @@ from zendesk import ZendeskError
import json
import mock
from student.tests.test_microsite import fake_microsite_get_value
from student.tests.test_configuration_overrides import fake_get_value
@mock.patch.dict("django.conf.settings.FEATURES", {"ENABLE_FEEDBACK_SUBMISSION": True})
......@@ -193,14 +193,14 @@ class SubmitFeedbackTest(TestCase):
self.assertEqual(zendesk_mock_instance.mock_calls, expected_zendesk_calls)
self._assert_datadog_called(datadog_mock, with_tags=True)
@mock.patch("microsite_configuration.microsite.get_value", fake_microsite_get_value)
def test_valid_request_anon_user_microsite(self, zendesk_mock_class, datadog_mock):
@mock.patch("openedx.core.djangoapps.site_configuration.helpers.get_value", fake_get_value)
def test_valid_request_anon_user_configuration_override(self, zendesk_mock_class, datadog_mock):
"""
Test a valid request from an anonymous user to a mocked out microsite
Test a valid request from an anonymous user to a mocked out site with configuration override
The response should have a 200 (success) status code, and a ticket with
the given information should have been submitted via the Zendesk API with the additional
tag that will come from microsite configuration
tag that will come from site configuration override.
"""
zendesk_mock_instance = zendesk_mock_class.return_value
zendesk_mock_instance.create_ticket.return_value = 42
......
......@@ -14,7 +14,7 @@ from django.http import (Http404, HttpResponse, HttpResponseNotAllowed,
import dogstats_wrapper as dog_stats_api
from edxmako.shortcuts import render_to_response
import zendesk
from openedx.core.djangoapps.theming.helpers import get_value as get_themed_value
from openedx.core.djangoapps.site_configuration import helpers as configuration_helpers
import calc
import track.views
......@@ -233,7 +233,7 @@ def _record_feedback_in_zendesk(
# Per edX support, we would like to be able to route white label feedback items
# via tagging
white_label_org = get_themed_value('course_org_filter')
white_label_org = configuration_helpers.get_value('course_org_filter')
if white_label_org:
zendesk_tags = zendesk_tags + ["whitelabel_{org}".format(org=white_label_org)]
......@@ -368,7 +368,7 @@ def submit_feedback(request):
details,
tags,
additional_info,
support_email=get_themed_value('email_from_address', settings.DEFAULT_FROM_EMAIL)
support_email=configuration_helpers.get_value('email_from_address', settings.DEFAULT_FROM_EMAIL)
)
_record_feedback_in_datadog(tags)
......
......@@ -19,7 +19,7 @@ def url_class(is_active):
%>
<li>
<a href="${tab.link_func(course, reverse) | h}" class="${tab_class}">
Test Microsite Tab: ${_(tab.name) | h}
Test Site Tab: ${_(tab.name) | h}
% if tab_is_active:
<span class="sr">, current location</span>
%endif
......
......@@ -10,7 +10,7 @@ from django.utils.translation import ugettext as _
<footer>
<div class="colophon">
<div class="colophon-about">
<p>This is a Test Microsite footer</p>
<p>This is a Test Site footer</p>
</div>
</div>
......
......@@ -12,9 +12,8 @@ from xmodule.course_module import CourseDescriptor
from django.conf import settings
from opaque_keys.edx.locations import SlashSeparatedCourseKey
from microsite_configuration import microsite
from django.contrib.staticfiles.storage import staticfiles_storage
from openedx.core.djangoapps.content.course_overviews.models import CourseOverview
from openedx.core.djangoapps.site_configuration import helpers as configuration_helpers
def get_visible_courses(org=None, filter_=None):
......@@ -28,33 +27,32 @@ def get_visible_courses(org=None, filter_=None):
filter_ (dict): Optional parameter that allows custom filtering by
fields on the course.
"""
microsite_org = microsite.get_value('course_org_filter')
current_site_org = configuration_helpers.get_value('course_org_filter')
if org and microsite_org:
# When called in the context of a microsite, return an empty result if the org
# passed by the caller does not match the designated microsite org.
if org and current_site_org:
# Return an empty result if the org passed by the caller does not match the designated site org.
courses = CourseOverview.get_all_courses(
org=org,
filter_=filter_,
) if org == microsite_org else []
) if org == current_site_org else []
else:
# We only make it to this point if one of org or microsite_org is defined.
# If both org and microsite_org were defined, the code would have fallen into the
# We only make it to this point if one of org or current_site_org is defined.
# If both org and current_site_org were defined, the code would have fallen into the
# first branch of the conditional above, wherein an equality check is performed.
target_org = org or microsite_org
target_org = org or current_site_org
courses = CourseOverview.get_all_courses(org=target_org, filter_=filter_)
courses = sorted(courses, key=lambda course: course.number)
# When called in the context of a microsite, filtering can stop here.
if microsite_org:
# Filtering can stop here.
if current_site_org:
return courses
# 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
subdomain = microsite.get_value('subdomain', 'default')
# this is legacy format, which also handle dev case, which should not filter
subdomain = configuration_helpers.get_value('subdomain', 'default')
if hasattr(settings, 'COURSE_LISTINGS') and subdomain in settings.COURSE_LISTINGS and not settings.DEBUG:
filtered_visible_ids = frozenset(
[SlashSeparatedCourseKey.from_deprecated_string(c) for c in settings.COURSE_LISTINGS[subdomain]]
......@@ -63,9 +61,9 @@ def get_visible_courses(org=None, filter_=None):
if filtered_visible_ids:
return [course for course in courses if course.id in filtered_visible_ids]
else:
# Filter out any courses belonging to a microsite, to avoid leaking these.
microsite_orgs = microsite.get_all_orgs()
return [course for course in courses if course.location.org not in microsite_orgs]
# Filter out any courses based on current org, to avoid leaking these.
orgs = configuration_helpers.get_all_orgs()
return [course for course in courses if course.location.org not in orgs]
def get_university_for_request():
......@@ -73,4 +71,4 @@ def get_university_for_request():
Return the university name specified for the domain, or None
if no university was specified
"""
return microsite.get_value('university')
return configuration_helpers.get_value('university')
......@@ -19,9 +19,9 @@ from django.conf import settings
from django.utils.translation import ugettext as _
from django.contrib.staticfiles.storage import staticfiles_storage
from microsite_configuration import microsite
from edxmako.shortcuts import marketing_link
from branding.models import BrandingApiConfig
from openedx.core.djangoapps.site_configuration import helpers as configuration_helpers
log = logging.getLogger("edx.footer")
......@@ -117,7 +117,7 @@ def _footer_copyright():
u"\u00A9 {org_name}. All rights reserved except where noted. "
u"EdX, Open edX and the edX and Open EdX logos are registered trademarks "
u"or trademarks of edX Inc."
).format(org_name=microsite.get_value('PLATFORM_NAME', settings.PLATFORM_NAME))
).format(org_name=configuration_helpers.get_value('PLATFORM_NAME', settings.PLATFORM_NAME))
def _footer_openedx_link():
......@@ -145,7 +145,7 @@ def _footer_social_links():
Returns: list
"""
platform_name = microsite.get_value('platform_name', settings.PLATFORM_NAME)
platform_name = configuration_helpers.get_value('platform_name', settings.PLATFORM_NAME)
links = []
for social_name in settings.SOCIAL_MEDIA_FOOTER_NAMES:
......@@ -222,7 +222,7 @@ def _footer_mobile_links(is_secure):
Returns: list
"""
platform_name = microsite.get_value('platform_name', settings.PLATFORM_NAME)
platform_name = configuration_helpers.get_value('platform_name', settings.PLATFORM_NAME)
mobile_links = []
if settings.FEATURES.get('ENABLE_FOOTER_MOBILE_APP_LINKS'):
......@@ -256,8 +256,8 @@ def _footer_logo_img(is_secure):
Returns:
Absolute url to logo
"""
logo_name = microsite.get_value('FOOTER_ORGANIZATION_IMAGE', settings.FOOTER_ORGANIZATION_IMAGE)
# `logo_name` is looked up from the microsite configuration,
logo_name = configuration_helpers.get_value('FOOTER_ORGANIZATION_IMAGE', settings.FOOTER_ORGANIZATION_IMAGE)
# `logo_name` is looked up from the configuration,
# which falls back on the Django settings, which loads it from
# `lms.env.json`, which is created and managed by Ansible. Because of
# this runaround, we lose a lot of the flexibility that Django's
......@@ -298,7 +298,7 @@ def _absolute_url(is_secure, url_path):
unicode
"""
site_name = microsite.get_value('SITE_NAME', settings.SITE_NAME)
site_name = configuration_helpers.get_value('SITE_NAME', settings.SITE_NAME)
parts = ("https" if is_secure else "http", site_name, url_path, '', '', '')
return urlparse.urlunparse(parts)
......@@ -327,14 +327,14 @@ def _absolute_url_staticfile(is_secure, name):
return _absolute_url(is_secure, url_path)
def get_microsite_url(name):
def get_configuration_url(name):
"""
Look up and return the value for given url name in microsite configuration.
URLs are saved in "urls" dictionary inside Microsite Configuration.
Look up and return the value for given url name in configuration.
URLs are saved in "urls" dictionary inside configuration.
Return 'EMPTY_URL' if given url name is not defined in microsite configuration urls.
Return 'EMPTY_URL' if given url name is not defined in configuration urls.
"""
urls = microsite.get_value("urls", default={})
urls = configuration_helpers.get_value("urls", default={})
return urls.get(name) or EMPTY_URL
......@@ -342,15 +342,15 @@ def get_url(name):
"""
Lookup and return page url, lookup is performed in the following order
1. get microsite url, If microsite URL override exists, return it
1. get url, If configuration URL override exists, return it
2. Otherwise return the marketing URL.
:return: string containing page url.
"""
# If a microsite URL override exists, return it. Otherwise return the marketing URL.
microsite_url = get_microsite_url(name)
if microsite_url != EMPTY_URL:
return microsite_url
# If a configuration URL override exists, return it. Otherwise return the marketing URL.
configuration_url = get_configuration_url(name)
if configuration_url != EMPTY_URL:
return configuration_url
# get marketing link, if marketing is disabled then platform url will be used instead.
url = marketing_link(name)
......@@ -360,7 +360,7 @@ def get_url(name):
def get_base_url(is_secure):
"""
Return Base URL for site/microsite.
Return Base URL for site.
Arguments:
is_secure (bool): If true, use HTTPS as the protocol.
"""
......@@ -374,9 +374,9 @@ def get_logo_url(is_secure=True):
is_secure (bool): If true, use HTTPS as the protocol.
"""
# if the MicrositeConfiguration has a value for the logo_image_url
# if the configuration has an overide value for the logo_image_url
# let's use that
image_url = microsite.get_value('logo_image_url')
image_url = configuration_helpers.get_value('logo_image_url')
if image_url:
return _absolute_url_staticfile(
is_secure=is_secure,
......@@ -384,7 +384,7 @@ def get_logo_url(is_secure=True):
)
# otherwise, use the legacy means to configure this
university = microsite.get_value('university')
university = configuration_helpers.get_value('university')
if university:
return staticfiles_storage.url('images/{uni}-on-edx-logo.png'.format(uni=university))
......
......@@ -16,26 +16,25 @@ from edxmako.shortcuts import render_to_response
import student.views
from student.models import CourseEnrollment
import courseware.views.views
from microsite_configuration import microsite
from edxmako.shortcuts import marketing_link
from util.cache import cache_if_anonymous
from util.json_request import JsonResponse
import branding.api as branding_api
from openedx.core.djangoapps.site_configuration import helpers as configuration_helpers
log = logging.getLogger(__name__)
def get_course_enrollments(user):
"""
Returns the course enrollments for the passed in user within the context of a microsite, that
Returns the course enrollments for the passed in user within the context of current org, that
is filtered by course_org_filter
"""
enrollments = CourseEnrollment.enrollments_for_user(user)
microsite_org = microsite.get_value('course_org_filter')
if microsite_org:
course_org = configuration_helpers.get_value('course_org_filter')
if course_org:
site_enrollments = [
enrollment for enrollment in enrollments if enrollment.course_id.org == microsite_org
enrollment for enrollment in enrollments if enrollment.course_id.org == course_org
]
else:
site_enrollments = [
......@@ -52,11 +51,11 @@ def index(request):
'''
if request.user.is_authenticated():
# For microsites, only redirect to dashboard if user has
# Only redirect to dashboard if user has
# courses in his/her dashboard. Otherwise UX is a bit cryptic.
# In this case, we want to have the user stay on a course catalog
# page to make it easier to browse for courses (and register)
if microsite.get_value(
if configuration_helpers.get_value(
'ALWAYS_REDIRECT_HOMEPAGE_TO_DASHBOARD_FOR_AUTHENTICATED_USER',
settings.FEATURES.get('ALWAYS_REDIRECT_HOMEPAGE_TO_DASHBOARD_FOR_AUTHENTICATED_USER', True)):
return redirect(reverse('dashboard'))
......@@ -71,7 +70,7 @@ def index(request):
request.GET = req_new
return ssl_login(request)
enable_mktg_site = microsite.get_value(
enable_mktg_site = configuration_helpers.get_value(
'ENABLE_MKTG_SITE',
settings.FEATURES.get('ENABLE_MKTG_SITE', False)
)
......@@ -82,7 +81,7 @@ def index(request):
domain = request.META.get('HTTP_HOST')
# keep specialized logic for Edge until we can migrate over Edge to fully use
# microsite definitions
# configuration.
if domain and 'edge.edx.org' in domain:
return redirect(reverse("signin_user"))
......@@ -99,7 +98,7 @@ def courses(request):
to that. Otherwise, if subdomain branding is on, this is the university
profile page. Otherwise, it's the edX courseware.views.views.courses page
"""
enable_mktg_site = microsite.get_value(
enable_mktg_site = configuration_helpers.get_value(
'ENABLE_MKTG_SITE',
settings.FEATURES.get('ENABLE_MKTG_SITE', False)
)
......
......@@ -51,7 +51,7 @@ from instructor_task.subtasks import (
)
from util.query import use_read_replica_if_available
from util.date_utils import get_default_time_display
from openedx.core.djangoapps.theming import helpers as theming_helpers
from openedx.core.djangoapps.site_configuration import helpers as configuration_helpers
log = logging.getLogger('edx.celery.task')
......@@ -116,7 +116,7 @@ def _get_course_email_context(course):
'course_end_date': course_end_date,
'account_settings_url': 'https://{}{}'.format(settings.SITE_NAME, reverse('account_settings')),
'email_settings_url': 'https://{}{}'.format(settings.SITE_NAME, reverse('dashboard')),
'platform_name': theming_helpers.get_value('PLATFORM_NAME', settings.PLATFORM_NAME),
'platform_name': configuration_helpers.get_value('PLATFORM_NAME', settings.PLATFORM_NAME),
}
return email_context
......@@ -388,7 +388,7 @@ def _get_source_address(course_id, course_title, truncate=True):
return from_addr_format.format(
course_title=course_title_no_quotes,
course_name=course_name,
from_email=theming_helpers.get_value(
from_email=configuration_helpers.get_value(
'email_from_address',
settings.BULK_EMAIL_DEFAULT_FROM_EMAIL
)
......
......@@ -568,7 +568,7 @@ def get_asset_url_by_slug(asset_slug):
def get_certificate_header_context(is_secure=True):
"""
Return data to be used in Certificate Header,
data returned should be customized according to the microsite settings
data returned should be customized according to the site configuration.
"""
data = dict(
logo_src=branding_api.get_logo_url(is_secure),
......@@ -581,7 +581,7 @@ def get_certificate_header_context(is_secure=True):
def get_certificate_footer_context():
"""
Return data to be used in Certificate Footer,
data returned should be customized according to the microsite settings
data returned should be customized according to the site configuration.
"""
data = dict()
......
......@@ -74,10 +74,10 @@ class CertificateHtmlViewConfigurationFactory(DjangoModelFactory):
"certificate_type": "XSeries"
},
"microsites": {
"testmicrosite": {
"company_about_url": "http://www.testmicrosite.org/about-us",
"company_privacy_url": "http://www.testmicrosite.org/edx-privacy-policy",
"company_tos_url": "http://www.testmicrosite.org/edx-terms-service"
"test-site": {
"company_about_url": "http://www.test-site.org/about-us",
"company_privacy_url": "http://www.test-site.org/edx-privacy-policy",
"company_tos_url": "http://www.test-site.org/edx-terms-service"
}
}
}"""
......
......@@ -659,7 +659,7 @@ class CertificatesBrandingTest(TestCase):
def setUp(self):
super(CertificatesBrandingTest, self).setUp()
@set_microsite(settings.MICROSITE_CONFIGURATION['test_microsite']['domain_prefix'])
@set_microsite(settings.MICROSITE_CONFIGURATION['test_site']['domain_prefix'])
def test_certificate_header_data(self):
"""
Test that get_certificate_header_context from certificates api
......@@ -675,16 +675,16 @@ class CertificatesBrandingTest(TestCase):
['logo_src', 'logo_url']
)
self.assertIn(
settings.MICROSITE_CONFIGURATION['test_microsite']['logo_image_url'],
settings.MICROSITE_CONFIGURATION['test_site']['logo_image_url'],
data['logo_src']
)
self.assertIn(
settings.MICROSITE_CONFIGURATION['test_microsite']['SITE_NAME'],
settings.MICROSITE_CONFIGURATION['test_site']['SITE_NAME'],
data['logo_url']
)
@set_microsite(settings.MICROSITE_CONFIGURATION['test_microsite']['domain_prefix'])
@set_microsite(settings.MICROSITE_CONFIGURATION['test_site']['domain_prefix'])
def test_certificate_footer_data(self):
"""
Test that get_certificate_footer_context from certificates api returns
......@@ -700,21 +700,21 @@ class CertificatesBrandingTest(TestCase):
['company_about_url', 'company_privacy_url', 'company_tos_url']
)
# ABOUT is present in MICROSITE_CONFIGURATION['test_microsite']["urls"] so web certificate will use that url
# ABOUT is present in MICROSITE_CONFIGURATION['test_site']["urls"] so web certificate will use that url
self.assertIn(
settings.MICROSITE_CONFIGURATION['test_microsite']["urls"]['ABOUT'],
settings.MICROSITE_CONFIGURATION['test_site']["urls"]['ABOUT'],
data['company_about_url']
)
# PRIVACY is present in MICROSITE_CONFIGURATION['test_microsite']["urls"] so web certificate will use that url
# PRIVACY is present in MICROSITE_CONFIGURATION['test_site']["urls"] so web certificate will use that url
self.assertIn(
settings.MICROSITE_CONFIGURATION['test_microsite']["urls"]['PRIVACY'],
settings.MICROSITE_CONFIGURATION['test_site']["urls"]['PRIVACY'],
data['company_privacy_url']
)
# TOS_AND_HONOR is present in MICROSITE_CONFIGURATION['test_microsite']["urls"],
# TOS_AND_HONOR is present in MICROSITE_CONFIGURATION['test_site']["urls"],
# so web certificate will use that url
self.assertIn(
settings.MICROSITE_CONFIGURATION['test_microsite']["urls"]['TOS_AND_HONOR'],
settings.MICROSITE_CONFIGURATION['test_site']["urls"]['TOS_AND_HONOR'],
data['company_tos_url']
)
......@@ -271,7 +271,7 @@ class MicrositeCertificatesViewsTests(ModuleStoreTestCase):
"logo_url": "http://www.edx.org"
},
"microsites": {
"testmicrosite": {
"test-site": {
"accomplishment_class_append": "accomplishment-certificate",
"platform_name": "platform_microsite",
"company_about_url": "http://www.microsite.org/about-us",
......@@ -301,7 +301,7 @@ class MicrositeCertificatesViewsTests(ModuleStoreTestCase):
self.assertIn('platform_microsite', response.content)
# logo url is taken from microsite configuration setting
self.assertIn('http://test_microsite.localhost', response.content)
self.assertIn('http://test_site.localhost', response.content)
self.assertIn('This is special microsite aware company_about_description content', response.content)
self.assertIn('Microsite title', response.content)
......
......@@ -20,10 +20,10 @@ from courseware.access import has_access
from edxmako.shortcuts import render_to_response
from edxmako.template import Template
from eventtracking import tracker
from microsite_configuration import microsite
from opaque_keys import InvalidKeyError
from opaque_keys.edx.keys import CourseKey
from openedx.core.lib.courses import course_image_url
from openedx.core.djangoapps.site_configuration import helpers as configuration_helpers
from student.models import LinkedInAddToProfileConfiguration
from util import organizations_helpers as organization_api
from util.views import handle_500
......@@ -45,7 +45,6 @@ from certificates.models import (
CertificateHtmlViewConfiguration,
CertificateSocialNetworks)
log = logging.getLogger(__name__)
......@@ -250,9 +249,9 @@ def _update_social_context(request, context, course, user, user_certificate, pla
"""
Updates context dictionary with info required for social sharing.
"""
share_settings = microsite.get_value("SOCIAL_SHARING_SETTINGS", settings.SOCIAL_SHARING_SETTINGS)
share_settings = configuration_helpers.get_value("SOCIAL_SHARING_SETTINGS", settings.SOCIAL_SHARING_SETTINGS)
context['facebook_share_enabled'] = share_settings.get('CERTIFICATE_FACEBOOK', False)
context['facebook_app_id'] = microsite.get_value("FACEBOOK_APP_ID", settings.FACEBOOK_APP_ID)
context['facebook_app_id'] = configuration_helpers.get_value("FACEBOOK_APP_ID", settings.FACEBOOK_APP_ID)
context['facebook_share_text'] = share_settings.get(
'CERTIFICATE_FACEBOOK_TEXT',
_("I completed the {course_title} course on {platform_name}.").format(
......@@ -420,14 +419,13 @@ def _render_certificate_template(request, context, course, user_certificate):
return render_to_response("certificates/valid.html", context)
def _update_microsite_context(context, configuration):
def _update_configuration_context(context, configuration):
"""
Updates context with microsites data.
Microsites will need to be able to override any hard coded
Site Configuration will need to be able to override any hard coded
content that was put into the context in the
_update_certificate_context() call above. For example the
'company_about_description' talks about edX, which we most likely
do not want to keep in a microsite
do not want to keep in configurations.
So we need to re-apply any configuration/content that
we are sourcing from the database. This is somewhat duplicative of
the code at the beginning of this method, but we
......@@ -435,10 +433,10 @@ def _update_microsite_context(context, configuration):
require that to be set up early on in the pipeline
"""
microsite_config_key = microsite.get_value('domain_prefix')
microsites_config = configuration.get("microsites", {})
if microsite_config_key and microsites_config:
context.update(microsites_config.get(microsite_config_key, {}))
config_key = configuration_helpers.get_value('domain_prefix')
config = configuration.get("microsites", {})
if config_key and config:
context.update(config.get(config_key, {}))
def _update_badge_context(context, course, user):
......@@ -502,7 +500,7 @@ def render_html_view(request, user_id, course_id):
raise Http404
preview_mode = request.GET.get('preview', None)
platform_name = microsite.get_value("platform_name", settings.PLATFORM_NAME)
platform_name = configuration_helpers.get_value("platform_name", settings.PLATFORM_NAME)
configuration = CertificateHtmlViewConfiguration.get_config()
# Create the initial view context, bootstrapping with Django settings and passed-in values
context = {}
......@@ -578,8 +576,8 @@ def render_html_view(request, user_id, course_id):
# Append badge info
_update_badge_context(context, course, user)
# Append microsite overrides
_update_microsite_context(context, configuration)
# Append site configuration overrides
_update_configuration_context(context, configuration)
# Add certificate header/footer data to current context
context.update(get_certificate_header_context(is_secure=request.is_secure()))
......
......@@ -12,11 +12,11 @@ from django.utils.translation import ugettext as _
from edx_rest_api_client.exceptions import HttpClientError
import requests
from microsite_configuration import microsite
from request_cache.middleware import RequestCache
from student.models import UNENROLL_DONE
from openedx.core.djangoapps.commerce.utils import ecommerce_api_client, is_commerce_service_configured
from openedx.core.djangoapps.theming.helpers import get_value
from openedx.core.djangoapps.site_configuration import helpers as configuration_helpers
from openedx.core.djangoapps.theming import helpers as theming_helpers
log = logging.getLogger(__name__)
......@@ -197,7 +197,9 @@ def generate_refund_notification_body(student, refund_ids): # pylint: disable=i
"To process this request, please visit the link(s) below."
).format(username=student.username, email=student.email)
ecommerce_url_root = get_value('ECOMMERCE_PUBLIC_URL_ROOT', settings.ECOMMERCE_PUBLIC_URL_ROOT)
ecommerce_url_root = configuration_helpers.get_value(
'ECOMMERCE_PUBLIC_URL_ROOT', settings.ECOMMERCE_PUBLIC_URL_ROOT,
)
refund_urls = [urljoin(ecommerce_url_root, '/dashboard/refunds/{}/'.format(refund_id))
for refund_id in refund_ids]
......@@ -209,9 +211,9 @@ def send_refund_notification(course_enrollment, refund_ids):
tags = ['auto_refund']
if microsite.is_request_in_microsite():
if theming_helpers.is_request_in_themed_site():
# this is not presently supported with the external service.
raise NotImplementedError("Unable to send refund processing emails to microsite teams.")
raise NotImplementedError("Unable to send refund processing emails to support teams.")
student = course_enrollment.user
subject = _("[Refund] User-Requested Refund")
......
......@@ -198,11 +198,11 @@ class TestRefundSignal(TestCase):
self.assertTrue(mock_send_notification.called)
self.assertTrue(mock_log_warning.called)
@mock.patch('commerce.signals.microsite.is_request_in_microsite', return_value=True)
def test_notification_microsite(self, mock_is_request_in_microsite): # pylint: disable=unused-argument
@mock.patch('openedx.core.djangoapps.theming.helpers.is_request_in_themed_site', return_value=True)
def test_notification_themed_site(self, mock_is_request_in_themed_site): # pylint: disable=unused-argument
"""
Ensure the notification function raises an Exception if used in the
context of microsites.
context of themed site.
"""
with self.assertRaises(NotImplementedError):
send_refund_notification(self.course_enrollment, [1, 2, 3])
......
......@@ -5,7 +5,7 @@ from urlparse import urljoin
from django.conf import settings
from commerce.models import CommerceConfiguration
from openedx.core.djangoapps.theming import helpers
from openedx.core.djangoapps.site_configuration import helpers as configuration_helpers
log = logging.getLogger(__name__)
......@@ -61,7 +61,10 @@ class EcommerceService(object):
Example:
http://localhost:8002/basket/single_item/
"""
ecommerce_url_root = helpers.get_value('ECOMMERCE_PUBLIC_URL_ROOT', settings.ECOMMERCE_PUBLIC_URL_ROOT)
ecommerce_url_root = configuration_helpers.get_value(
'ECOMMERCE_PUBLIC_URL_ROOT',
settings.ECOMMERCE_PUBLIC_URL_ROOT,
)
return urljoin(ecommerce_url_root, self.config.single_course_checkout_page)
def checkout_page_url(self, sku):
......
......@@ -9,10 +9,10 @@ from django.views.decorators.csrf import csrf_exempt
from commerce.models import CommerceConfiguration
from edxmako.shortcuts import render_to_response
from microsite_configuration import microsite
from lms.djangoapps.verify_student.models import SoftwareSecurePhotoVerification
from openedx.core.djangoapps.theming.helpers import is_request_in_themed_site
from shoppingcart.processors.CyberSource2 import is_user_payment_error
from openedx.core.djangoapps.site_configuration import helpers as configuration_helpers
log = logging.getLogger(__name__)
......@@ -21,14 +21,22 @@ log = logging.getLogger(__name__)
@csrf_exempt
def checkout_cancel(_request):
""" Checkout/payment cancellation view. """
context = {'payment_support_email': microsite.get_value('payment_support_email', settings.PAYMENT_SUPPORT_EMAIL)}
context = {
'payment_support_email': configuration_helpers.get_value(
'payment_support_email', settings.PAYMENT_SUPPORT_EMAIL,
)
}
return render_to_response("commerce/checkout_cancel.html", context)
@csrf_exempt
def checkout_error(_request):
""" Checkout/payment error view. """
context = {'payment_support_email': microsite.get_value('payment_support_email', settings.PAYMENT_SUPPORT_EMAIL)}
context = {
'payment_support_email': configuration_helpers.get_value(
'payment_support_email', settings.PAYMENT_SUPPORT_EMAIL,
)
}
return render_to_response("commerce/checkout_error.html", context)
......@@ -39,7 +47,7 @@ def checkout_receipt(request):
page_title = _('Receipt')
is_payment_complete = True
payment_support_email = microsite.get_value('payment_support_email', settings.PAYMENT_SUPPORT_EMAIL)
payment_support_email = configuration_helpers.get_value('payment_support_email', settings.PAYMENT_SUPPORT_EMAIL)
payment_support_link = '<a href=\"mailto:{email}\">{email}</a>'.format(email=payment_support_email)
is_cybersource = all(k in request.POST for k in ('signed_field_names', 'decision', 'reason_code'))
......@@ -77,7 +85,7 @@ def checkout_receipt(request):
context = {
'page_title': page_title,
'is_payment_complete': is_payment_complete,
'platform_name': microsite.get_value('platform_name', settings.PLATFORM_NAME),
'platform_name': configuration_helpers.get_value('platform_name', settings.PLATFORM_NAME),
'verified': SoftwareSecurePhotoVerification.verification_valid_or_pending(request.user).exists(),
'error_summary': error_summary,
'error_text': error_text,
......
......@@ -15,7 +15,7 @@ from wiki.models import URLPath, Article
from courseware.courses import get_course_by_id
from course_wiki.utils import course_wiki_slug
from opaque_keys.edx.locations import SlashSeparatedCourseKey
from openedx.core.djangoapps.theming.helpers import get_value as get_themed_value
from openedx.core.djangoapps.site_configuration import helpers as configuration_helpers
log = logging.getLogger(__name__)
......@@ -112,8 +112,9 @@ def get_or_create_root():
pass
starting_content = "\n".join((
_("Welcome to the {platform_name} Wiki").format(platform_name=get_themed_value('PLATFORM_NAME',
settings.PLATFORM_NAME)),
_("Welcome to the {platform_name} Wiki").format(
platform_name=configuration_helpers.get_value('PLATFORM_NAME', settings.PLATFORM_NAME),
),
"===",
_("Visit a course wiki to add an article."),
))
......
......@@ -19,7 +19,6 @@ from xmodule.modulestore.exceptions import ItemNotFoundError
from static_replace import replace_static_urls
from xmodule.modulestore import ModuleStoreEnum
from xmodule.x_module import STUDENT_VIEW
from microsite_configuration import microsite
from courseware.access import has_access
from courseware.date_summary import (
......@@ -37,6 +36,7 @@ import branding
from opaque_keys.edx.keys import UsageKey
from openedx.core.djangoapps.content.course_overviews.models import CourseOverview
from openedx.core.djangoapps.site_configuration import helpers as configuration_helpers
log = logging.getLogger(__name__)
......@@ -380,7 +380,7 @@ def get_courses(user, org=None, filter_=None):
"""
courses = branding.get_visible_courses(org=org, filter_=filter_)
permission_name = microsite.get_value(
permission_name = configuration_helpers.get_value(
'COURSE_CATALOG_VISIBILITY_PERMISSION',
settings.COURSE_CATALOG_VISIBILITY_PERMISSION
)
......@@ -394,7 +394,7 @@ def get_permission_for_course_about():
"""
Returns the CourseOverview object for the course after checking for access.
"""
return microsite.get_value(
return configuration_helpers.get_value(
'COURSE_ABOUT_VISIBILITY_PERMISSION',
settings.COURSE_ABOUT_VISIBILITY_PERMISSION
)
......
......@@ -89,13 +89,13 @@ class CoursesTest(ModuleStoreTestCase):
"""
Verify that org filtering performs as expected, and that an empty result
is returned if the org passed by the caller does not match the designated
microsite org.
org.
"""
primary = 'primary'
alternate = 'alternate'
def _fake_get_value(value, default=None):
"""Used to stub out microsite.get_value()."""
"""Used to stub out site_configuration.helpers.get_value()."""
if value == 'course_org_filter':
return alternate
......@@ -120,17 +120,20 @@ class CoursesTest(ModuleStoreTestCase):
all(course.org == primary_course.org for course in filtered_courses)
)
with mock.patch('microsite_configuration.microsite.get_value', autospec=True) as mock_get_value:
with mock.patch(
'openedx.core.djangoapps.site_configuration.helpers.get_value',
autospec=True,
) as mock_get_value:
mock_get_value.side_effect = _fake_get_value
# Request filtering for an org distinct from the designated microsite org.
# Request filtering for an org distinct from the designated org.
no_courses = get_courses(user, org=primary)
self.assertEqual(no_courses, [])
# Request filtering for an org matching the designated microsite org.
microsite_courses = get_courses(user, org=alternate)
# Request filtering for an org matching the designated org.
site_courses = get_courses(user, org=alternate)
self.assertTrue(
all(course.org == alternate_course.org for course in microsite_courses)
all(course.org == alternate_course.org for course in site_courses)
)
def test_get_courses_with_filter(self):
......
......@@ -1346,7 +1346,7 @@ class ProgressPageTests(ModuleStoreTestCase):
self.assertContains(resp, u"Download Your Certificate")
@ddt.data(
*itertools.product(((48, 4, True), (48, 4, False)), (True, False))
*itertools.product(((49, 4, True), (49, 4, False)), (True, False))
)
@ddt.unpack
def test_query_counts(self, (sql_calls, mongo_calls, self_paced), self_paced_enabled):
......
......@@ -77,7 +77,7 @@ from openedx.core.djangoapps.credit.api import (
is_user_eligible_for_credit,
is_credit_course
)
from openedx.core.djangoapps.theming import helpers as theming_helpers
from openedx.core.djangoapps.site_configuration import helpers as configuration_helpers
from shoppingcart.utils import is_shopping_cart_enabled
from openedx.core.djangoapps.self_paced.models import SelfPacedConfiguration
from student.models import UserTestGroup, CourseEnrollment
......@@ -141,7 +141,7 @@ def courses(request):
if not settings.FEATURES.get('ENABLE_COURSE_DISCOVERY'):
courses_list = get_courses(request.user)
if theming_helpers.get_value(
if configuration_helpers.get_value(
"ENABLE_COURSE_SORTING_BY_START_DATE",
settings.FEATURES["ENABLE_COURSE_SORTING_BY_START_DATE"]
):
......@@ -542,7 +542,7 @@ def course_about(request, course_id):
course_details = CourseDetails.populate(course)
modes = CourseMode.modes_for_course_dict(course_key)
if theming_helpers.get_value('ENABLE_MKTG_SITE', settings.FEATURES.get('ENABLE_MKTG_SITE', False)):
if configuration_helpers.get_value('ENABLE_MKTG_SITE', settings.FEATURES.get('ENABLE_MKTG_SITE', False)):
return redirect(reverse('info', args=[course.id.to_deprecated_string()]))
registered = registered_for_course(course, request.user)
......@@ -834,7 +834,7 @@ def _get_cert_data(student, course, course_key, is_active, enrollment_mode):
not SoftwareSecurePhotoVerification.user_is_verified(student)
if missing_required_verification or cert_downloadable_status['is_unverified']:
platform_name = theming_helpers.get_value('PLATFORM_NAME', settings.PLATFORM_NAME)
platform_name = configuration_helpers.get_value('PLATFORM_NAME', settings.PLATFORM_NAME)
return CertData(
CertificateStatuses.unverified,
'Certificate unavailable',
......@@ -1157,7 +1157,7 @@ def generate_user_cert(request, course_id):
log.info(u"Anon user trying to generate certificate for %s", course_id)
return HttpResponseBadRequest(
_('You must be signed in to {platform_name} to create a certificate.').format(
platform_name=theming_helpers.get_value('PLATFORM_NAME', settings.PLATFORM_NAME)
platform_name=configuration_helpers.get_value('PLATFORM_NAME', settings.PLATFORM_NAME)
)
)
......@@ -1273,7 +1273,7 @@ FINANCIAL_ASSISTANCE_HEADER = _(
' financial assistance program.'
).format(
percent_sign="%",
platform_name=theming_helpers.get_value('PLATFORM_NAME', settings.PLATFORM_NAME)
platform_name=configuration_helpers.get_value('PLATFORM_NAME', settings.PLATFORM_NAME)
).split('\n')
......@@ -1393,7 +1393,7 @@ def financial_assistance_form(request):
'student_faq_url': marketing_link('FAQ'),
'dashboard_url': reverse('dashboard'),
'account_settings_url': reverse('account_settings'),
'platform_name': theming_helpers.get_value('PLATFORM_NAME', settings.PLATFORM_NAME),
'platform_name': configuration_helpers.get_value('PLATFORM_NAME', settings.PLATFORM_NAME),
'user_details': {
'email': user.email,
'username': user.username,
......
......@@ -22,10 +22,9 @@ from submissions import api as sub_api # installed from the edx-submissions rep
from student.models import anonymous_id_for_user
from openedx.core.djangoapps.user_api.models import UserPreference
from microsite_configuration import microsite
from xmodule.modulestore.django import modulestore
from xmodule.modulestore.exceptions import ItemNotFoundError
from openedx.core.djangoapps.theming import helpers as theming_helpers
from openedx.core.djangoapps.site_configuration import helpers as configuration_helpers
log = logging.getLogger(__name__)
......@@ -300,7 +299,7 @@ def get_email_params(course, auto_enroll, secure=True, course_key=None, display_
course_key = course_key or course.id.to_deprecated_string()
display_name = display_name or course.display_name_with_default_escaped
stripped_site_name = microsite.get_value(
stripped_site_name = configuration_helpers.get_value(
'SITE_NAME',
settings.SITE_NAME
)
......@@ -372,7 +371,7 @@ def send_mail_to_student(student, param_dict, language=None):
if 'display_name' in param_dict:
param_dict['course_name'] = param_dict['display_name']
param_dict['site_name'] = microsite.get_value(
param_dict['site_name'] = configuration_helpers.get_value(
'SITE_NAME',
param_dict['site_name']
)
......@@ -380,8 +379,8 @@ def send_mail_to_student(student, param_dict, language=None):
subject = None
message = None
# see if we are running in a microsite and that there is an
# activation email template definition available as configuration, if so, then render that
# see if there is an activation email template definition available as configuration,
# if so, then render that
message_type = param_dict['message']
email_template_dict = {
......@@ -427,7 +426,7 @@ def send_mail_to_student(student, param_dict, language=None):
# Email subject *must not* contain newlines
subject = ''.join(subject.splitlines())
from_address = theming_helpers.get_value(
from_address = configuration_helpers.get_value(
'email_from_address',
settings.DEFAULT_FROM_EMAIL
)
......
......@@ -8,10 +8,10 @@ from django.conf import settings
from django.utils.translation import ugettext as _
from courseware.courses import get_course_by_id
from instructor.enrollment_report import BaseAbstractEnrollmentReportProvider
from microsite_configuration import microsite
from shoppingcart.models import RegistrationCodeRedemption, PaidCourseRegistration, CouponRedemption, OrderItem, \
InvoiceTransaction
from student.models import CourseEnrollment, ManualEnrollmentAudit
from openedx.core.djangoapps.site_configuration import helpers as configuration_helpers
class PaidCourseEnrollmentReportProvider(BaseAbstractEnrollmentReportProvider):
......@@ -29,7 +29,7 @@ class PaidCourseEnrollmentReportProvider(BaseAbstractEnrollmentReportProvider):
# check the user enrollment role
if user.is_staff:
platform_name = microsite.get_value('platform_name', settings.PLATFORM_NAME)
platform_name = configuration_helpers.get_value('platform_name', settings.PLATFORM_NAME)
enrollment_role = _('{platform_name} Staff').format(platform_name=platform_name)
elif is_course_staff:
enrollment_role = _('Course Staff')
......
......@@ -40,7 +40,6 @@ from courseware.tests.factories import (
from courseware.tests.helpers import LoginEnrollmentTestCase
from django_comment_common.models import FORUM_ROLE_COMMUNITY_TA
from django_comment_common.utils import seed_permissions_roles
from microsite_configuration import microsite
from shoppingcart.models import (
RegistrationCodeRedemption, Order, CouponRedemption,
PaidCourseRegistration, Coupon, Invoice, CourseRegistrationCode, CourseRegistrationCodeInvoiceItem,
......@@ -71,6 +70,7 @@ from certificates.models import CertificateStatuses
from openedx.core.djangoapps.course_groups.cohorts import set_course_cohort_settings
from openedx.core.lib.xblock_utils import grade_histogram
from openedx.core.djangoapps.site_configuration import helpers as configuration_helpers
from .test_tools import msk_from_problem_urlname
......@@ -958,7 +958,7 @@ class TestInstructorAPIEnrollment(SharedModuleStoreTestCase, LoginEnrollmentTest
cls.course = CourseFactory.create()
# Email URL values
cls.site_name = microsite.get_value(
cls.site_name = configuration_helpers.get_value(
'SITE_NAME',
settings.SITE_NAME
)
......@@ -1709,7 +1709,7 @@ class TestInstructorAPIBulkBetaEnrollment(SharedModuleStoreTestCase, LoginEnroll
super(TestInstructorAPIBulkBetaEnrollment, cls).setUpClass()
cls.course = CourseFactory.create()
# Email URL values
cls.site_name = microsite.get_value(
cls.site_name = configuration_helpers.get_value(
'SITE_NAME',
settings.SITE_NAME
)
......
......@@ -38,8 +38,6 @@ from util.json_request import JsonResponse, JsonResponseBadRequest
from util.views import require_global_staff
from instructor.views.instructor_task_helpers import extract_email_features, extract_task_features
from microsite_configuration import microsite
from courseware.access import has_access
from courseware.courses import get_course_with_access, get_course_by_id
from django.contrib.auth.models import User
......@@ -111,7 +109,7 @@ from opaque_keys.edx.keys import CourseKey, UsageKey
from opaque_keys.edx.locations import SlashSeparatedCourseKey
from opaque_keys import InvalidKeyError
from openedx.core.djangoapps.course_groups.cohorts import is_course_cohorted
from openedx.core.djangoapps.theming import helpers as theming_helpers
from openedx.core.djangoapps.site_configuration import helpers as configuration_helpers
log = logging.getLogger(__name__)
......@@ -287,7 +285,10 @@ def register_and_enroll_students(request, course_id): # pylint: disable=too-man
The failure will be messaged in a response in the browser.
"""
if not microsite.get_value('ALLOW_AUTOMATED_SIGNUPS', settings.FEATURES.get('ALLOW_AUTOMATED_SIGNUPS', False)):
if not configuration_helpers.get_value(
'ALLOW_AUTOMATED_SIGNUPS',
settings.FEATURES.get('ALLOW_AUTOMATED_SIGNUPS', False),
):
return HttpResponseForbidden()
course_id = SlashSeparatedCourseKey.from_deprecated_string(course_id)
......@@ -534,7 +535,7 @@ def create_and_enroll_user(email, username, name, country, password, course_id,
'message': 'account_creation_and_enrollment',
'email_address': email,
'password': password,
'platform_name': microsite.get_value('platform_name', settings.PLATFORM_NAME),
'platform_name': configuration_helpers.get_value('platform_name', settings.PLATFORM_NAME),
})
send_mail_to_student(email, email_params)
except Exception as ex: # pylint: disable=broad-except
......@@ -1198,7 +1199,7 @@ def get_students_features(request, course_id, csv=False): # pylint: disable=red
available_features = instructor_analytics.basic.AVAILABLE_FEATURES
# Allow for microsites to be able to define additional columns.
# Allow for sites to be able to define additional columns.
# Note that adding additional columns has the potential to break
# the student profile report due to a character limit on the
# asynchronous job input which in this case is a JSON string
......@@ -1206,7 +1207,7 @@ def get_students_features(request, course_id, csv=False): # pylint: disable=red
# TODO: Refactor the student profile report code to remove the list of columns
# that should be included in the report from the asynchronous job input.
# We need to clone the list because we modify it below
query_features = list(microsite.get_value('student_profile_download_fields', []))
query_features = list(configuration_helpers.get_value('student_profile_download_fields', []))
if not query_features:
query_features = [
......@@ -1691,15 +1692,15 @@ def generate_registration_codes(request, course_id):
)
registration_codes.append(generated_registration_code)
site_name = microsite.get_value('SITE_NAME', 'localhost')
site_name = configuration_helpers.get_value('SITE_NAME', 'localhost')
quantity = course_code_number
discount = (float(quantity * course_price) - float(sale_price))
course_url = '{base_url}{course_about}'.format(
base_url=microsite.get_value('SITE_NAME', settings.SITE_NAME),
base_url=configuration_helpers.get_value('SITE_NAME', settings.SITE_NAME),
course_about=reverse('about_course', kwargs={'course_id': course_id.to_deprecated_string()})
)
dashboard_url = '{base_url}{dashboard}'.format(
base_url=microsite.get_value('SITE_NAME', settings.SITE_NAME),
base_url=configuration_helpers.get_value('SITE_NAME', settings.SITE_NAME),
dashboard=reverse('dashboard')
)
......@@ -1709,7 +1710,7 @@ def generate_registration_codes(request, course_id):
log.exception('Exception at creating pdf file.')
pdf_file = None
from_address = theming_helpers.get_value('email_from_address', settings.DEFAULT_FROM_EMAIL)
from_address = configuration_helpers.get_value('email_from_address', settings.DEFAULT_FROM_EMAIL)
context = {
'invoice': sale_invoice,
'site_name': site_name,
......@@ -1722,11 +1723,14 @@ def generate_registration_codes(request, course_id):
'registration_codes': registration_codes,
'currency_symbol': settings.PAID_COURSE_REGISTRATION_CURRENCY[1],
'course_url': course_url,
'platform_name': microsite.get_value('platform_name', settings.PLATFORM_NAME),
'platform_name': configuration_helpers.get_value('platform_name', settings.PLATFORM_NAME),
'dashboard_url': dashboard_url,
'contact_email': from_address,
'corp_address': microsite.get_value('invoice_corp_address', settings.INVOICE_CORP_ADDRESS),
'payment_instructions': microsite.get_value('invoice_payment_instructions', settings. INVOICE_PAYMENT_INSTRUCTIONS),
'corp_address': configuration_helpers.get_value('invoice_corp_address', settings.INVOICE_CORP_ADDRESS),
'payment_instructions': configuration_helpers.get_value(
'invoice_payment_instructions',
settings. INVOICE_PAYMENT_INSTRUCTIONS,
),
'date': time.strftime("%m/%d/%Y")
}
# composes registration codes invoice email
......@@ -1740,11 +1744,11 @@ def generate_registration_codes(request, course_id):
csv_writer = csv.writer(csv_file)
for registration_code in registration_codes:
full_redeem_code_url = 'http://{base_url}{redeem_code_url}'.format(
base_url=microsite.get_value('SITE_NAME', settings.SITE_NAME),
base_url=configuration_helpers.get_value('SITE_NAME', settings.SITE_NAME),
redeem_code_url=reverse('register_code_redemption', kwargs={'registration_code': registration_code.code})
)
csv_writer.writerow([registration_code.code, full_redeem_code_url])
finance_email = microsite.get_value('finance_email', settings.FINANCE_EMAIL)
finance_email = configuration_helpers.get_value('finance_email', settings.FINANCE_EMAIL)
if finance_email:
# append the finance email into the recipient_list
recipient_list.append(finance_email)
......@@ -2485,13 +2489,13 @@ def send_email(request, course_id):
subject = request.POST.get("subject")
message = request.POST.get("message")
# allow two branding points to come from Microsites: which CourseEmailTemplate should be used
# allow two branding points to come from Site Configuration: which CourseEmailTemplate should be used
# and what the 'from' field in the email should be
#
# If these are None (because we are not in a Microsite or they are undefined in Microsite config) than
# If these are None (there is no site configuration enabled for the current site) than
# the system will use normal system defaults
template_name = microsite.get_value('course_email_template_name')
from_addr = microsite.get_value('course_email_from_addr')
template_name = configuration_helpers.get_value('course_email_template_name')
from_addr = configuration_helpers.get_value('course_email_from_addr')
# Create the CourseEmail object. This is saved immediately, so that
# any transaction that has been pending up to this point will also be
......
......@@ -17,7 +17,6 @@ from django.core.serializers.json import DjangoJSONEncoder
from django.core.urlresolvers import reverse
from opaque_keys.edx.keys import UsageKey
import xmodule.graders as xmgraders
from microsite_configuration import microsite
from student.models import CourseEnrollmentAllowed
from edx_proctoring.api import get_all_exam_attempts
from courseware.models import StudentModule
......@@ -25,6 +24,7 @@ from certificates.models import GeneratedCertificate
from django.db.models import Count
from certificates.models import CertificateStatuses
from grades.context import grading_context_for_course
from openedx.core.djangoapps.site_configuration import helpers as configuration_helpers
STUDENT_FEATURES = ('id', 'username', 'first_name', 'last_name', 'is_staff', 'email')
......@@ -430,7 +430,7 @@ def course_registration_features(features, registration_codes, csv_type):
:param features:
:param csv_type:
"""
site_name = microsite.get_value('SITE_NAME', settings.SITE_NAME)
site_name = configuration_helpers.get_value('SITE_NAME', settings.SITE_NAME)
registration_features = [x for x in COURSE_REGISTRATION_FEATURES if x in features]
course_registration_dict = dict((feature, getattr(registration_code, feature)) for feature in registration_features)
......
......@@ -16,7 +16,6 @@ from django.views.generic import View
from edx_oauth2_provider import views as dop_views # django-oauth2-provider views
from oauth2_provider import models as dot_models, views as dot_views # django-oauth-toolkit
from openedx.core.djangoapps.theming import helpers
from openedx.core.lib.token_utils import JwtBuilder
from . import adapters
......
......@@ -33,7 +33,6 @@ from django.core.mail.message import EmailMessage
from xmodule.modulestore.django import modulestore
from eventtracking import tracker
from openedx.core.djangoapps.theming.helpers import get_value as get_themed_value
from courseware.courses import get_course_by_id
from config_models.models import ConfigurationModel
from course_modes.models import CourseMode
......@@ -52,8 +51,8 @@ from .exceptions import (
UnexpectedOrderItemStatus,
ItemNotFoundInCartException
)
from microsite_configuration import microsite
from shoppingcart.pdf import PDFInvoice
from openedx.core.djangoapps.site_configuration import helpers as configuration_helpers
log = logging.getLogger("shoppingcart")
......@@ -272,7 +271,9 @@ class Order(models.Model):
if is_order_type_business:
for cart_item in cart_items:
if hasattr(cart_item, 'paidcourseregistration'):
course_reg_code_item = CourseRegCodeItem.add_to_order(self, cart_item.paidcourseregistration.course_id, cart_item.qty)
course_reg_code_item = CourseRegCodeItem.add_to_order(
self, cart_item.paidcourseregistration.course_id, cart_item.qty,
)
# update the discounted prices if coupon redemption applied
course_reg_code_item.list_price = cart_item.list_price
course_reg_code_item.unit_cost = cart_item.unit_cost
......@@ -282,7 +283,9 @@ class Order(models.Model):
else:
for cart_item in cart_items:
if hasattr(cart_item, 'courseregcodeitem'):
paid_course_registration = PaidCourseRegistration.add_to_order(self, cart_item.courseregcodeitem.course_id)
paid_course_registration = PaidCourseRegistration.add_to_order(
self, cart_item.courseregcodeitem.course_id,
)
# update the discounted prices if coupon redemption applied
paid_course_registration.list_price = cart_item.list_price
paid_course_registration.unit_cost = cart_item.unit_cost
......@@ -370,7 +373,7 @@ class Order(models.Model):
dashboard=reverse('dashboard')
)
try:
from_address = microsite.get_value(
from_address = configuration_helpers.get_value(
'email_from_address',
settings.PAYMENT_SUPPORT_EMAIL
)
......@@ -391,9 +394,11 @@ class Order(models.Model):
username=self.user.username, email=self.user.email
),
'has_billing_info': settings.FEATURES['STORE_BILLING_INFO'],
'platform_name': microsite.get_value('platform_name', settings.PLATFORM_NAME),
'payment_support_email': microsite.get_value('payment_support_email', settings.PAYMENT_SUPPORT_EMAIL),
'payment_email_signature': microsite.get_value('payment_email_signature'),
'platform_name': configuration_helpers.get_value('platform_name', settings.PLATFORM_NAME),
'payment_support_email': configuration_helpers.get_value(
'payment_support_email', settings.PAYMENT_SUPPORT_EMAIL,
),
'payment_email_signature': configuration_helpers.get_value('payment_email_signature'),
}
)
email = EmailMessage(
......@@ -463,7 +468,7 @@ class Order(models.Model):
# this should return all of the objects with the correct types of the
# subclasses
orderitems = OrderItem.objects.filter(order=self).select_subclasses()
site_name = microsite.get_value('SITE_NAME', settings.SITE_NAME)
site_name = configuration_helpers.get_value('SITE_NAME', settings.SITE_NAME)
if self.order_type == OrderTypes.BUSINESS:
self.update_order_type()
......@@ -1909,7 +1914,7 @@ class CertificateItem(OrderItem):
user_email=course_enrollment.user.email,
order_number=order_number)
to_email = [settings.PAYMENT_SUPPORT_EMAIL]
from_email = microsite.get_value('payment_support_email', settings.PAYMENT_SUPPORT_EMAIL)
from_email = configuration_helpers.get_value('payment_support_email', settings.PAYMENT_SUPPORT_EMAIL)
try:
send_mail(subject, message, from_email, to_email, fail_silently=False)
except Exception as exception: # pylint: disable=broad-except
......@@ -2005,7 +2010,7 @@ class CertificateItem(OrderItem):
is_professional_mode_verified = self.course_enrollment.is_professional_enrollment()
if is_enrollment_mode_verified:
domain = microsite.get_value('SITE_NAME', settings.SITE_NAME)
domain = configuration_helpers.get_value('SITE_NAME', settings.SITE_NAME)
path = reverse('verify_student_verify_now', kwargs={'course_id': unicode(self.course_id)})
verification_url = "http://{domain}{path}".format(domain=domain, path=path)
......@@ -2197,7 +2202,7 @@ class Donation(OrderItem):
u"We greatly appreciate this generous contribution and your support of the {platform_name} mission. "
u"This receipt was prepared to support charitable contributions for tax purposes. "
u"We confirm that neither goods nor services were provided in exchange for this gift."
).format(platform_name=get_themed_value('PLATFORM_NAME', settings.PLATFORM_NAME))
).format(platform_name=configuration_helpers.get_value('PLATFORM_NAME', settings.PLATFORM_NAME))
@classmethod
def _line_item_description(cls, course_id=None):
......@@ -2230,8 +2235,9 @@ class Donation(OrderItem):
# The donation is for the organization as a whole, not a specific course
else:
return _(u"Donation for {platform_name}").format(platform_name=get_themed_value('PLATFORM_NAME',
settings.PLATFORM_NAME))
return _(u"Donation for {platform_name}").format(
platform_name=configuration_helpers.get_value('PLATFORM_NAME', settings.PLATFORM_NAME),
)
@property
def single_item_receipt_context(self):
......@@ -2256,8 +2262,8 @@ class Donation(OrderItem):
data['name'] = unicode(self.course_id)
data['category'] = unicode(self.course_id.org)
else:
data['name'] = get_themed_value('PLATFORM_NAME', settings.PLATFORM_NAME)
data['category'] = get_themed_value('PLATFORM_NAME', settings.PLATFORM_NAME)
data['name'] = configuration_helpers.get_value('PLATFORM_NAME', settings.PLATFORM_NAME)
data['category'] = configuration_helpers.get_value('PLATFORM_NAME', settings.PLATFORM_NAME)
return data
@property
......
......@@ -12,8 +12,8 @@ from reportlab.lib.units import mm
from reportlab.lib.styles import getSampleStyleSheet
from reportlab.platypus import Paragraph
from reportlab.platypus.tables import Table, TableStyle
from microsite_configuration import microsite
from xmodule.modulestore.django import ModuleI18nService
from openedx.core.djangoapps.site_configuration import helpers as configuration_helpers
log = logging.getLogger("PDF Generation")
......@@ -90,24 +90,26 @@ class PDFInvoice(object):
# From settings
self.currency = settings.PAID_COURSE_REGISTRATION_CURRENCY[1]
self.logo_path = microsite.get_value("PDF_RECEIPT_LOGO_PATH", settings.PDF_RECEIPT_LOGO_PATH)
self.cobrand_logo_path = microsite.get_value(
self.logo_path = configuration_helpers.get_value("PDF_RECEIPT_LOGO_PATH", settings.PDF_RECEIPT_LOGO_PATH)
self.cobrand_logo_path = configuration_helpers.get_value(
"PDF_RECEIPT_COBRAND_LOGO_PATH", settings.PDF_RECEIPT_COBRAND_LOGO_PATH
)
self.tax_label = microsite.get_value("PDF_RECEIPT_TAX_ID_LABEL", settings.PDF_RECEIPT_TAX_ID_LABEL)
self.tax_id = microsite.get_value("PDF_RECEIPT_TAX_ID", settings.PDF_RECEIPT_TAX_ID)
self.footer_text = microsite.get_value("PDF_RECEIPT_FOOTER_TEXT", settings.PDF_RECEIPT_FOOTER_TEXT)
self.disclaimer_text = microsite.get_value("PDF_RECEIPT_DISCLAIMER_TEXT", settings.PDF_RECEIPT_DISCLAIMER_TEXT)
self.billing_address_text = microsite.get_value(
self.tax_label = configuration_helpers.get_value("PDF_RECEIPT_TAX_ID_LABEL", settings.PDF_RECEIPT_TAX_ID_LABEL)
self.tax_id = configuration_helpers.get_value("PDF_RECEIPT_TAX_ID", settings.PDF_RECEIPT_TAX_ID)
self.footer_text = configuration_helpers.get_value("PDF_RECEIPT_FOOTER_TEXT", settings.PDF_RECEIPT_FOOTER_TEXT)
self.disclaimer_text = configuration_helpers.get_value(
"PDF_RECEIPT_DISCLAIMER_TEXT", settings.PDF_RECEIPT_DISCLAIMER_TEXT,
)
self.billing_address_text = configuration_helpers.get_value(
"PDF_RECEIPT_BILLING_ADDRESS", settings.PDF_RECEIPT_BILLING_ADDRESS
)
self.terms_conditions_text = microsite.get_value(
self.terms_conditions_text = configuration_helpers.get_value(
"PDF_RECEIPT_TERMS_AND_CONDITIONS", settings.PDF_RECEIPT_TERMS_AND_CONDITIONS
)
self.brand_logo_height = microsite.get_value(
self.brand_logo_height = configuration_helpers.get_value(
"PDF_RECEIPT_LOGO_HEIGHT_MM", settings.PDF_RECEIPT_LOGO_HEIGHT_MM
) * mm
self.cobrand_logo_height = microsite.get_value(
self.cobrand_logo_height = configuration_helpers.get_value(
"PDF_RECEIPT_COBRAND_LOGO_HEIGHT_MM", settings.PDF_RECEIPT_COBRAND_LOGO_HEIGHT_MM
) * mm
......
......@@ -33,7 +33,7 @@ from edxmako.shortcuts import render_to_string
from shoppingcart.models import Order
from shoppingcart.processors.exceptions import *
from shoppingcart.processors.helpers import get_processor_config
from microsite_configuration import microsite
from openedx.core.djangoapps.site_configuration import helpers as configuration_helpers
def process_postpay_callback(params, **kwargs):
......@@ -243,8 +243,8 @@ def record_purchase(params, order):
def get_processor_decline_html(params):
"""Have to parse through the error codes to return a helpful message"""
# see if we have an override in the microsites
payment_support_email = microsite.get_value('payment_support_email', settings.PAYMENT_SUPPORT_EMAIL)
# see if we have an override in the site configuration
payment_support_email = configuration_helpers.get_value('payment_support_email', settings.PAYMENT_SUPPORT_EMAIL)
msg = _(
"Sorry! Our payment processor did not accept your payment. "
......@@ -267,8 +267,8 @@ def get_processor_decline_html(params):
def get_processor_exception_html(exception):
"""Return error HTML associated with exception"""
# see if we have an override in the microsites
payment_support_email = microsite.get_value('payment_support_email', settings.PAYMENT_SUPPORT_EMAIL)
# see if we have an override in the site configuration
payment_support_email = configuration_helpers.get_value('payment_support_email', settings.PAYMENT_SUPPORT_EMAIL)
if isinstance(exception, CCProcessorDataException):
msg = _(
"Sorry! Our payment processor sent us back a payment confirmation "
......
......@@ -37,7 +37,7 @@ from edxmako.shortcuts import render_to_string
from shoppingcart.models import Order
from shoppingcart.processors.exceptions import *
from shoppingcart.processors.helpers import get_processor_config
from microsite_configuration import microsite
from openedx.core.djangoapps.site_configuration import helpers as configuration_helpers
log = logging.getLogger(__name__)
......@@ -461,7 +461,7 @@ def _get_processor_decline_html(params):
unicode: The rendered HTML.
"""
payment_support_email = microsite.get_value('payment_support_email', settings.PAYMENT_SUPPORT_EMAIL)
payment_support_email = configuration_helpers.get_value('payment_support_email', settings.PAYMENT_SUPPORT_EMAIL)
return _format_error_html(
_(
"Sorry! Our payment processor did not accept your payment. "
......@@ -491,7 +491,7 @@ def _get_processor_exception_html(exception):
unicode: The rendered HTML.
"""
payment_support_email = microsite.get_value('payment_support_email', settings.PAYMENT_SUPPORT_EMAIL)
payment_support_email = configuration_helpers.get_value('payment_support_email', settings.PAYMENT_SUPPORT_EMAIL)
if isinstance(exception, CCProcessorDataException):
return _format_error_html(
_(
......
......@@ -4,13 +4,13 @@ These methods should be shared among all processor implementations,
but should NOT be imported by modules outside this package.
"""
from django.conf import settings
from microsite_configuration import microsite
from openedx.core.djangoapps.site_configuration import helpers as configuration_helpers
def get_processor_config():
"""
Return a dictionary of configuration settings for the active credit card processor.
If we're in a microsite and overrides are available, return those instead.
If configuration overrides are available, return those instead.
Returns:
dict
......@@ -21,10 +21,10 @@ def get_processor_config():
settings.CC_PROCESSOR_NAME, {}
)
# Check whether we're in a microsite that overrides our configuration
# If so, find the microsite-specific configuration in the 'microsites'
# Check whether configuration override exists,
# If so, find the configuration-specific cybersource config in the configurations.
# sub-key of the normal processor configuration.
config_key = microsite.get_value('cybersource_config_key')
config_key = configuration_helpers.get_value('cybersource_config_key')
if config_key:
config = config['microsites'][config_key]
......
......@@ -38,7 +38,7 @@ TEST_CC_PROCESSOR = {
'ORDERPAGE_VERSION': '7',
'PURCHASE_ENDPOINT': '',
'microsites': {
'test_microsite': {
'test_site': {
'SHARED_SECRET': 'secret_override',
'MERCHANT_ID': 'edx_test_override',
'SERIAL_NUMBER': '12345_override',
......@@ -50,12 +50,12 @@ TEST_CC_PROCESSOR = {
}
def fakemicrosite(name, default=None):
def fake_site(name, default=None): # pylint: disable=unused-argument
"""
This is a test mocking function to return a microsite configuration
This is a test mocking function to return a site configuration
"""
if name == 'cybersource_config_key':
return 'test_microsite'
return 'test_site'
else:
return None
......@@ -70,12 +70,12 @@ class CyberSourceTests(TestCase):
self.assertEqual(settings.CC_PROCESSOR['CyberSource']['MERCHANT_ID'], 'edx_test')
self.assertEqual(settings.CC_PROCESSOR['CyberSource']['SHARED_SECRET'], 'secret')
def test_microsite_no_override_settings(self):
def test_site_no_override_settings(self):
self.assertEqual(get_processor_config()['MERCHANT_ID'], 'edx_test')
self.assertEqual(get_processor_config()['SHARED_SECRET'], 'secret')
@patch("microsite_configuration.microsite.get_value", fakemicrosite)
def test_microsite_override_settings(self):
@patch("openedx.core.djangoapps.site_configuration.helpers.get_value", fake_site)
def test_site_override_settings(self):
self.assertEqual(get_processor_config()['MERCHANT_ID'], 'edx_test_override')
self.assertEqual(get_processor_config()['SHARED_SECRET'], 'secret_override')
......
......@@ -3,13 +3,13 @@ Utility methods for the Shopping Cart app
"""
from django.conf import settings
from microsite_configuration import microsite
from pdfminer.pdfparser import PDFParser
from pdfminer.pdfdocument import PDFDocument
from pdfminer.pdfinterp import PDFResourceManager, PDFPageInterpreter
from pdfminer.converter import PDFPageAggregator
from pdfminer.pdfpage import PDFPage
from pdfminer.layout import LAParams, LTTextBox, LTTextLine, LTFigure
from openedx.core.djangoapps.site_configuration import helpers as configuration_helpers
def is_shopping_cart_enabled():
......@@ -17,12 +17,12 @@ def is_shopping_cart_enabled():
Utility method to check the various configuration to verify that
all of the settings have been enabled
"""
enable_paid_course_registration = microsite.get_value(
enable_paid_course_registration = configuration_helpers.get_value(
'ENABLE_PAID_COURSE_REGISTRATION',
settings.FEATURES.get('ENABLE_PAID_COURSE_REGISTRATION')
)
enable_shopping_cart = microsite.get_value(
enable_shopping_cart = configuration_helpers.get_value(
'ENABLE_SHOPPING_CART',
settings.FEATURES.get('ENABLE_SHOPPING_CART')
)
......
......@@ -20,7 +20,6 @@ from django.views.decorators.csrf import csrf_exempt
from util.bad_request_rate_limiter import BadRequestRateLimiter
from util.date_utils import get_default_time_display
from django.contrib.auth.decorators import login_required
from microsite_configuration import microsite
from edxmako.shortcuts import render_to_response
from opaque_keys.edx.locations import SlashSeparatedCourseKey
from opaque_keys.edx.locator import CourseLocator
......@@ -51,6 +50,7 @@ from .processors import (
import json
from .decorators import enforce_shopping_cart_enabled
from openedx.core.djangoapps.site_configuration import helpers as configuration_helpers
log = logging.getLogger("shoppingcart")
......@@ -169,7 +169,7 @@ def show_cart(request):
cart = Order.get_cart_for_user(request.user)
is_any_course_expired, expired_cart_items, expired_cart_item_names, valid_cart_item_tuples = \
verify_for_closed_enrollment(request.user, cart)
site_name = microsite.get_value('SITE_NAME', settings.SITE_NAME)
site_name = configuration_helpers.get_value('SITE_NAME', settings.SITE_NAME)
if is_any_course_expired:
for expired_item in expired_cart_items:
......@@ -190,7 +190,7 @@ def show_cart(request):
'form_html': form_html,
'currency_symbol': settings.PAID_COURSE_REGISTRATION_CURRENCY[1],
'currency': settings.PAID_COURSE_REGISTRATION_CURRENCY[0],
'enable_bulk_purchase': microsite.get_value('ENABLE_SHOPPING_CART_BULK_PURCHASE', True)
'enable_bulk_purchase': configuration_helpers.get_value('ENABLE_SHOPPING_CART_BULK_PURCHASE', True)
}
return render_to_response("shoppingcart/shopping_cart.html", context)
......@@ -310,7 +310,7 @@ def register_code_redemption(request, registration_code):
"""
# Add some rate limiting here by re-using the RateLimitMixin as a helper class
site_name = microsite.get_value('SITE_NAME', settings.SITE_NAME)
site_name = configuration_helpers.get_value('SITE_NAME', settings.SITE_NAME)
limiter = BadRequestRateLimiter()
if limiter.is_rate_limit_exceeded(request):
AUDIT_LOG.warning("Rate limit exceeded in registration code redemption.")
......@@ -719,7 +719,7 @@ def billing_details(request):
'form_html': form_html,
'currency_symbol': settings.PAID_COURSE_REGISTRATION_CURRENCY[1],
'currency': settings.PAID_COURSE_REGISTRATION_CURRENCY[0],
'site_name': microsite.get_value('SITE_NAME', settings.SITE_NAME),
'site_name': configuration_helpers.get_value('SITE_NAME', settings.SITE_NAME),
}
return render_to_response("shoppingcart/billing_details.html", context)
elif request.method == "POST":
......@@ -914,7 +914,7 @@ def _show_receipt_html(request, order):
'shoppingcart_items': shoppingcart_items,
'any_refunds': any_refunds,
'instructions': instructions,
'site_name': microsite.get_value('SITE_NAME', settings.SITE_NAME),
'site_name': configuration_helpers.get_value('SITE_NAME', settings.SITE_NAME),
'order_type': order_type,
'appended_course_names': appended_course_names,
'appended_recipient_emails': appended_recipient_emails,
......
......@@ -68,7 +68,7 @@ class MarketingSiteViewTests(TestCase):
# check response with branding
resp = self.client.get(url, HTTP_HOST=settings.MICROSITE_TEST_HOSTNAME)
self.assertContains(resp, settings.MICROSITE_CONFIGURATION['test_microsite']['email_from_address'])
self.assertContains(resp, settings.MICROSITE_CONFIGURATION['test_site']['email_from_address'])
def test_500_microsites(self):
"""
......@@ -84,12 +84,12 @@ class MarketingSiteViewTests(TestCase):
self.assertContains(
resp,
'There has been a 500 error on the <em>{platform_name}</em> servers'.format(
platform_name=settings.MICROSITE_CONFIGURATION['test_microsite']['platform_name']
platform_name=settings.MICROSITE_CONFIGURATION['test_site']['platform_name']
),
status_code=500
)
self.assertContains(
resp,
settings.MICROSITE_CONFIGURATION['test_microsite']['email_from_address'],
settings.MICROSITE_CONFIGURATION['test_site']['email_from_address'],
status_code=500
)
......@@ -375,7 +375,7 @@ class StudentAccountLoginAndRegistrationTest(ThirdPartyAuthTestMixin, UrlResetMi
reverse("signin_user"),
HTTP_HOST=settings.MICROSITE_TEST_HOSTNAME
)
self.assertContains(resp, "Log into your Test Microsite Account")
self.assertContains(resp, "Log into your Test Site Account")
self.assertContains(resp, "login-form")
def test_microsite_uses_old_register_page(self):
......@@ -385,7 +385,7 @@ class StudentAccountLoginAndRegistrationTest(ThirdPartyAuthTestMixin, UrlResetMi
reverse("register_user"),
HTTP_HOST=settings.MICROSITE_TEST_HOSTNAME
)
self.assertContains(resp, "Register for Test Microsite")
self.assertContains(resp, "Register for Test Site")
self.assertContains(resp, "register-form")
def test_login_registration_xframe_protected(self):
......
......@@ -28,7 +28,8 @@ from external_auth.login_and_register import (
from lang_pref.api import released_languages, all_languages
from openedx.core.djangoapps.commerce.utils import ecommerce_api_client
from openedx.core.djangoapps.programs.models import ProgramsApiConfig
from openedx.core.djangoapps.theming.helpers import is_request_in_themed_site, get_value as get_themed_value
from openedx.core.djangoapps.theming.helpers import is_request_in_themed_site
from openedx.core.djangoapps.site_configuration import helpers as configuration_helpers
from openedx.core.djangoapps.user_api.accounts.api import request_password_change
from openedx.core.djangoapps.user_api.errors import UserNotFound
from openedx.core.lib.time_zone_utils import TIME_ZONE_CHOICES
......@@ -75,9 +76,9 @@ def login_and_registration_form(request, initial_mode="login"):
# If this is a themed site, revert to the old login/registration pages.
# We need to do this for now to support existing themes.
# Themed sites can use the new logistration page by setting
# 'ENABLE_COMBINED_LOGIN_REGISTRATION' in their theme/microsite
# 'ENABLE_COMBINED_LOGIN_REGISTRATION' in their
# configuration settings.
if is_request_in_themed_site() and not get_themed_value('ENABLE_COMBINED_LOGIN_REGISTRATION', False):
if is_request_in_themed_site() and not configuration_helpers.get_value('ENABLE_COMBINED_LOGIN_REGISTRATION', False):
if initial_mode == "login":
return old_login_view(request)
elif initial_mode == "register":
......@@ -108,7 +109,7 @@ def login_and_registration_form(request, initial_mode="login"):
'initial_mode': initial_mode,
'third_party_auth': _third_party_auth_context(request, redirect_to),
'third_party_auth_hint': third_party_auth_hint or '',
'platform_name': get_themed_value('PLATFORM_NAME', settings.PLATFORM_NAME),
'platform_name': configuration_helpers.get_value('PLATFORM_NAME', settings.PLATFORM_NAME),
# Include form descriptions retrieved from the user API.
# We could have the JS client make these requests directly,
......@@ -122,7 +123,7 @@ def login_and_registration_form(request, initial_mode="login"):
'responsive': True,
'allow_iframing': True,
'disable_courseware_js': True,
'disable_footer': not get_themed_value(
'disable_footer': not configuration_helpers.get_value(
'ENABLE_COMBINED_LOGIN_REGISTRATION_FOOTER',
settings.FEATURES['ENABLE_COMBINED_LOGIN_REGISTRATION_FOOTER']
),
......@@ -456,7 +457,7 @@ def account_settings_context(request):
'options': TIME_ZONE_CHOICES,
}
},
'platform_name': get_themed_value('PLATFORM_NAME', settings.PLATFORM_NAME),
'platform_name': configuration_helpers.get_value('PLATFORM_NAME', settings.PLATFORM_NAME),
'user_accounts_api_url': reverse("accounts_api", kwargs={'username': user.username}),
'user_preferences_api_url': reverse('preferences_api', kwargs={'username': user.username}),
'disable_courseware_js': True,
......
......@@ -11,11 +11,11 @@ from django.contrib.staticfiles.storage import staticfiles_storage
from badges.utils import badges_enabled
from edxmako.shortcuts import render_to_response, marketing_link
from microsite_configuration import microsite
from openedx.core.djangoapps.user_api.accounts.api import get_account_settings
from openedx.core.djangoapps.user_api.errors import UserNotFound, UserNotAuthorized
from openedx.core.djangoapps.user_api.preferences.api import get_user_preferences
from student.models import User
from openedx.core.djangoapps.site_configuration import helpers as configuration_helpers
@login_required
......@@ -92,7 +92,7 @@ def learner_profile_context(request, profile_username, user_is_staff):
'badges_logo': staticfiles_storage.url('certificates/images/backpack-logo.png'),
'badges_icon': staticfiles_storage.url('certificates/images/ico-mozillaopenbadges.png'),
'backpack_ui_img': staticfiles_storage.url('certificates/images/backpack-ui.png'),
'platform_name': microsite.get_value('platform_name', settings.PLATFORM_NAME),
'platform_name': configuration_helpers.get_value('platform_name', settings.PLATFORM_NAME),
},
'disable_courseware_js': True,
}
......
......@@ -18,7 +18,7 @@ from opaque_keys.edx.keys import CourseKey
from edxmako.shortcuts import render_to_response
from survey.models import SurveyForm
from microsite_configuration import microsite
from openedx.core.djangoapps.site_configuration import helpers as configuration_helpers
log = logging.getLogger("edx.survey")
......@@ -51,7 +51,7 @@ def view_student_survey(user, survey_name, course=None, redirect_url=None, is_re
# just remove that outer key to make the JSON payload simplier
existing_answers = survey.get_answers(user=user).get(user.id, {})
platform_name = microsite.get_value('platform_name', settings.PLATFORM_NAME)
platform_name = configuration_helpers.get_value('platform_name', settings.PLATFORM_NAME)
context = {
'existing_data_json': json.dumps(existing_answers),
......@@ -61,7 +61,7 @@ def view_student_survey(user, survey_name, course=None, redirect_url=None, is_re
'dashboard_redirect_url': dashboard_redirect_url,
'survey_form': survey.form,
'is_required': is_required,
'mail_to_link': microsite.get_value('email_from_address', settings.CONTACT_EMAIL),
'mail_to_link': configuration_helpers.get_value('email_from_address', settings.CONTACT_EMAIL),
'platform_name': platform_name,
'course': course,
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment