Merge pull request #1934 from edx/diana/drupal/fix-lms-links
Fix links between marketing site and courseware.
This commit is contained in:
@@ -17,6 +17,30 @@ from django.http import HttpResponse
|
||||
|
||||
from . import middleware
|
||||
from django.conf import settings
|
||||
from django.core.urlresolvers import reverse
|
||||
|
||||
|
||||
def marketing_link(name):
|
||||
"""Returns the correct URL for a link to the marketing site
|
||||
depending on if the marketing site is enabled
|
||||
|
||||
Since the marketing site is enabled by a setting, we have two
|
||||
possible URLs for certain links. This function is to decides
|
||||
which URL should be provided.
|
||||
"""
|
||||
|
||||
# link_map maps URLs from the marketing site to the old equivalent on
|
||||
# the Django site
|
||||
link_map = settings.MKTG_URL_LINK_MAP
|
||||
if settings.MITX_FEATURES.get('ENABLE_MKTG_SITE'):
|
||||
# special case for when we only want the root marketing URL
|
||||
if name == 'ROOT':
|
||||
return settings.MKTG_URLS.get('ROOT')
|
||||
return settings.MKTG_URLS.get('ROOT') + settings.MKTG_URLS.get(name)
|
||||
elif name in link_map:
|
||||
return reverse(link_map[name])
|
||||
else:
|
||||
return '#'
|
||||
|
||||
|
||||
def render_to_string(template_name, dictionary, context=None, namespace='main'):
|
||||
@@ -27,6 +51,7 @@ def render_to_string(template_name, dictionary, context=None, namespace='main'):
|
||||
context_dictionary = {}
|
||||
context_instance['settings'] = settings
|
||||
context_instance['MITX_ROOT_URL'] = settings.MITX_ROOT_URL
|
||||
context_instance['marketing_link'] = marketing_link
|
||||
|
||||
# In various testing contexts, there might not be a current request context.
|
||||
if middleware.requestcontext is not None:
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
|
||||
from django.conf import settings
|
||||
from mako.template import Template as MakoTemplate
|
||||
from mitxmako.shortcuts import marketing_link
|
||||
|
||||
from mitxmako import middleware
|
||||
|
||||
@@ -37,7 +38,6 @@ class Template(MakoTemplate):
|
||||
kwargs.update(overrides)
|
||||
super(Template, self).__init__(*args, **kwargs)
|
||||
|
||||
|
||||
def render(self, context_instance):
|
||||
"""
|
||||
This takes a render call with a context (from Django) and translates
|
||||
@@ -55,5 +55,6 @@ class Template(MakoTemplate):
|
||||
context_dictionary['settings'] = settings
|
||||
context_dictionary['MITX_ROOT_URL'] = settings.MITX_ROOT_URL
|
||||
context_dictionary['django_context'] = context_instance
|
||||
context_dictionary['marketing_link'] = marketing_link
|
||||
|
||||
return super(Template, self).render_unicode(**context_dictionary)
|
||||
|
||||
@@ -387,7 +387,7 @@ def change_enrollment(request):
|
||||
@ensure_csrf_cookie
|
||||
def accounts_login(request, error=""):
|
||||
|
||||
return render_to_response('accounts_login.html', {'error': error})
|
||||
return render_to_response('login.html', {'error': error})
|
||||
|
||||
|
||||
# Need different levels of logging
|
||||
|
||||
@@ -36,7 +36,6 @@ DISCUSSION_SETTINGS = {
|
||||
'MAX_COMMENT_DEPTH': 2,
|
||||
}
|
||||
|
||||
EDXMKTG_COOKIE_NAME = 'edxloggedin'
|
||||
|
||||
# Features
|
||||
MITX_FEATURES = {
|
||||
@@ -584,3 +583,24 @@ INSTALLED_APPS = (
|
||||
# Discussion forums
|
||||
'django_comment_client',
|
||||
)
|
||||
|
||||
######################### MARKETING SITE ###############################
|
||||
EDXMKTG_COOKIE_NAME = 'edxloggedin'
|
||||
MKTG_URLS = {
|
||||
'ROOT': '',
|
||||
'COURSES': '/courses/allschools/allsubjects/allcourses',
|
||||
'ABOUT': '/about-us',
|
||||
'JOBS': '/jobs',
|
||||
'PRESS': '/in-the-news',
|
||||
'FAQ': '/student-faq',
|
||||
'CONTACT': '/contact',
|
||||
'HOW_IT_WORKS': '/how-it-works',
|
||||
'SCHOOLS': '/schools',
|
||||
}
|
||||
MKTG_URL_LINK_MAP = {
|
||||
'ABOUT': 'about_edx',
|
||||
'CONTACT': 'contact',
|
||||
'FAQ': 'help_edx',
|
||||
'COURSES': 'courses',
|
||||
'ROOT': 'root',
|
||||
}
|
||||
|
||||
@@ -1,35 +0,0 @@
|
||||
<%! from django.core.urlresolvers import reverse %>
|
||||
<%inherit file="main.html" />
|
||||
<%namespace name='static' file='static_content.html'/>
|
||||
|
||||
<%block name="headextra">
|
||||
<style type="text/css">
|
||||
.login-box {
|
||||
display: block;
|
||||
position: relative;
|
||||
left: 0;
|
||||
margin: 100px auto;
|
||||
top: 0;
|
||||
height:500px;
|
||||
}
|
||||
|
||||
.login-box input[type=submit] {
|
||||
white-space: normal;
|
||||
height: auto !important;
|
||||
}
|
||||
|
||||
</style>
|
||||
</%block>
|
||||
|
||||
<section class='login-box'></section>
|
||||
|
||||
<script type="text/javascript">
|
||||
(function() {
|
||||
$(document).ready(
|
||||
function() {
|
||||
// show dialog
|
||||
$('#login').click();
|
||||
}
|
||||
);
|
||||
})(this)
|
||||
</script>
|
||||
@@ -328,7 +328,9 @@
|
||||
% else:
|
||||
<section class="empty-dashboard-message">
|
||||
<p>Looks like you haven't registered for any courses yet.</p>
|
||||
<a href="${reverse('courses')}">Find courses now!</a>
|
||||
<a href="${marketing_link('COURSES')}">
|
||||
Find courses now!
|
||||
</a>
|
||||
</section>
|
||||
% endif
|
||||
|
||||
|
||||
@@ -6,28 +6,33 @@
|
||||
<footer>
|
||||
<div class="colophon">
|
||||
<nav class="nav-colophon">
|
||||
<ol>
|
||||
<ol>
|
||||
<li class="nav-colophon-01">
|
||||
<a href="${reverse('about_edx')}">About</a>
|
||||
<a href="${marketing_link('ABOUT')}">
|
||||
About
|
||||
</a>
|
||||
</li>
|
||||
<li class="nav-colophon-02">
|
||||
<a href="${reverse('jobs')}">Jobs</a>
|
||||
<a href="${marketing_link('JOBS')}">
|
||||
Jobs
|
||||
</a>
|
||||
</li>
|
||||
<li class="nav-colophon-03">
|
||||
<a href="#">Press</a>
|
||||
<a href="${marketing_link('PRESS')}">
|
||||
Press
|
||||
</a>
|
||||
</li>
|
||||
<li class="nav-colophon-04">
|
||||
<a href="#">FAQ</a>
|
||||
<a href="${marketing_link('FAQ')}">
|
||||
FAQ
|
||||
</a>
|
||||
</li>
|
||||
<li class="nav-colophon-05">
|
||||
<a href="${reverse('contact')}">Contact</a>
|
||||
<a href="${marketing_link('CONTACT')}">
|
||||
Contact
|
||||
</a>
|
||||
</li>
|
||||
% if user.is_authenticated():
|
||||
<li class="nav-colophon-06">
|
||||
<a href="#">Help</a>
|
||||
</li>
|
||||
% endif
|
||||
</ol>
|
||||
</ol>
|
||||
</nav>
|
||||
|
||||
<div class="colophon-about">
|
||||
@@ -82,4 +87,4 @@
|
||||
</nav>
|
||||
</div>
|
||||
</footer>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -152,10 +152,14 @@
|
||||
|
||||
<div class="cta cta-help">
|
||||
<h3>Not Enrolled?</h3>
|
||||
<p><a href="#">Sign up for edX today!</a></p>
|
||||
<p><a href="${reverse('register_user')}">Sign up for edX today!</a></p>
|
||||
|
||||
<h3>Need Help?</h3>
|
||||
<p>Looking for help in logging in or with your edX account? <a href="#">View our help section for answers to commonly asked questions</a></p>
|
||||
<p>Looking for help in logging in or with your edX account?
|
||||
<a href="${marketing_link('FAQ')}">
|
||||
View our help section for answers to commonly asked questions.
|
||||
</a></p>
|
||||
|
||||
</div>
|
||||
</aside>
|
||||
</section>
|
||||
|
||||
@@ -38,7 +38,11 @@ site_status_msg = get_site_status_msg(course_id)
|
||||
<header class="global" aria-label="Global Navigation">
|
||||
% endif
|
||||
<nav>
|
||||
<h1 class="logo"><a href="${reverse('root')}"><img src="${static.url(branding.get_logo_url(request.META.get('HTTP_HOST')))}"/></a></h1>
|
||||
|
||||
<h1 class="logo">
|
||||
<a href="${marketing_link('ROOT')}">
|
||||
<img src="${static.url(branding.get_logo_url(request.META.get('HTTP_HOST')))}"/>
|
||||
</a></h1>
|
||||
|
||||
% if course:
|
||||
<h2><span class="provider">${course.org}:</span> ${course.number} ${course.display_name_with_default}</h2>
|
||||
@@ -48,11 +52,7 @@ site_status_msg = get_site_status_msg(course_id)
|
||||
|
||||
<ol class="left nav-global authenticated">
|
||||
<li class="nav-global-01">
|
||||
% if settings.MITX_FEATURES.get('ENABLE_MKTG_SITE'):
|
||||
<a href="${settings.MKTG_URLS.get('ROOT')}${settings.MKTG_URLS.get('COURSES')}">Find Courses</a>
|
||||
% else:
|
||||
<a href="${reverse('courses')}">Find Courses</a>
|
||||
% endif
|
||||
<a href="${marketing_link('COURSES')}">Find Courses</a>
|
||||
</li>
|
||||
</ol>
|
||||
<ol class="user">
|
||||
@@ -65,7 +65,10 @@ site_status_msg = get_site_status_msg(course_id)
|
||||
<li class="primary">
|
||||
<a href="#" class="dropdown">▾</a>
|
||||
<ul class="dropdown-menu">
|
||||
<li><a href="${reverse('help_edx')}">Help</a></li>
|
||||
<li>
|
||||
<a href="${marketing_link('FAQ')}">
|
||||
Help
|
||||
</a></li>
|
||||
<li><a href="${reverse('logout')}">Log Out</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
@@ -75,13 +78,13 @@ site_status_msg = get_site_status_msg(course_id)
|
||||
<ol class="left nav-global">
|
||||
% if settings.MITX_FEATURES.get('ENABLE_MKTG_SITE'):
|
||||
<li class="nav-global-01">
|
||||
<a href="${settings.MKTG_URLS.get('ROOT')}${settings.MKTG_URLS.get('HOW_IT_WORKS')}">How it Works</a>
|
||||
<a href="${marketing_link('HOW_IT_WORKS')}">How it Works</a>
|
||||
</li>
|
||||
<li class="nav-global-02">
|
||||
<a href="${settings.MKTG_URLS.get('ROOT')}${settings.MKTG_URLS.get('COURSES')}">Courses</a>
|
||||
<a href="marketing_link('COURSES')}">Courses</a>
|
||||
</li>
|
||||
<li class="nav-global-03">
|
||||
<a href="${settings.MKTG_URLS.get('ROOT')}${settings.MKTG_URLS.get('SCHOOLS')}">Schools</a>
|
||||
<a href="${marketing_link('SCHOOLS')}">Schools</a>
|
||||
</li>
|
||||
% endif
|
||||
% if not settings.MITX_FEATURES['DISABLE_LOGIN_BUTTON']:
|
||||
|
||||
@@ -252,7 +252,11 @@
|
||||
|
||||
<div class="cta cta-help">
|
||||
<h3>Need Help?</h3>
|
||||
<p>Need help in registering with edX? <a href="#">View our FAQs for answers to commonly asked questions</a>. Once registered, most questions can be answered in the course specific discussion forums or through the FAQs.</p>
|
||||
<p>Need help in registering with edX?
|
||||
<a href="${marketing_link('FAQ')}">
|
||||
View our FAQs for answers to commonly asked questions.
|
||||
</a>
|
||||
Once registered, most questions can be answered in the course specific discussion forums or through the FAQs.</p>
|
||||
</div>
|
||||
</aside>
|
||||
</section>
|
||||
|
||||
Reference in New Issue
Block a user