Files
edx-platform/lms/djangoapps/branding/views.py
Chris Dodge a3211a7405 Introduction of the Microsite feature which allows for limited multi-tenant branding on a subdomain basis, e.g. foo.edx.org and bar.edx.org
fix errorenous logic when running a microsite that could reside in a hosting environment with a marketing site in front of it

pep8/pylint fixes

address PR feedback, remove underscore from test hostname

more pep8/pylint cleanup. Skip test_microsites test, it works on localdev, not on Jenkins. Need to talk with QA team

manually add Ned's single-to-double quote fix

change aws.py runtimes so that the microsite_dir that is read from configuration is changed to a python path

Conflicts:
	lms/templates/help_modal.html
2014-01-14 14:36:01 -05:00

73 lines
2.4 KiB
Python

from django.conf import settings
from django.core.urlresolvers import reverse
from django.http import Http404
from django.shortcuts import redirect
from django_future.csrf import ensure_csrf_cookie
from edxmako.shortcuts import render_to_response
import student.views
import courseware.views
from microsite_configuration.middleware import MicrositeConfiguration
from edxmako.shortcuts import marketing_link
from util.cache import cache_if_anonymous
@ensure_csrf_cookie
@cache_if_anonymous
def index(request):
'''
Redirects to main page -- info page if user authenticated, or marketing if not
'''
if settings.COURSEWARE_ENABLED and request.user.is_authenticated():
return redirect(reverse('dashboard'))
if settings.FEATURES.get('AUTH_USE_MIT_CERTIFICATES'):
from external_auth.views import ssl_login
return ssl_login(request)
enable_mktg_site = MicrositeConfiguration.get_microsite_configuration_value(
'ENABLE_MKTG_SITE',
settings.FEATURES.get('ENABLE_MKTG_SITE', False)
)
if enable_mktg_site:
return redirect(settings.MKTG_URLS.get('ROOT'))
university = MicrositeConfiguration.match_university(request.META.get('HTTP_HOST'))
# keep specialized logic for Edge until we can migrate over Edge to fully use
# microsite definitions
if university == 'edge':
context = {
'suppress_toplevel_navigation': True
}
return render_to_response('university_profile/edge.html', context)
# we do not expect this case to be reached in cases where
# marketing and edge are enabled
return student.views.index(request, user=request.user)
@ensure_csrf_cookie
@cache_if_anonymous
def courses(request):
"""
Render the "find courses" page. If the marketing site is enabled, redirect
to that. Otherwise, if subdomain branding is on, this is the university
profile page. Otherwise, it's the edX courseware.views.courses page
"""
enable_mktg_site = settings.FEATURES.get('ENABLE_MKTG_SITE') or MicrositeConfiguration.get_microsite_configuration_value('ENABLE_MKTG_SITE', False)
if enable_mktg_site:
return redirect(marketing_link('COURSES'), permanent=True)
if not settings.FEATURES.get('COURSES_ARE_BROWSABLE'):
raise Http404
# we do not expect this case to be reached in cases where
# marketing is enabled or the courses are not browsable
return courseware.views.courses(request)