Commit c9a6fe18 by Diana Huang

Create new marketing_link function to abstract link generation

and use it for the new marketing site links.
parent e4e6c0dd
...@@ -17,7 +17,27 @@ from django.http import HttpResponse ...@@ -17,7 +17,27 @@ from django.http import HttpResponse
from . import middleware from . import middleware
from django.conf import settings 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 = {'ABOUT': 'about_edx',
'CONTACT': 'contact',
'FAQ': 'help_edx',
'COURSES': 'courses'}
if settings.MITX_FEATURES.get('ENABLE_MKTG_SITE'):
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'): def render_to_string(template_name, dictionary, context=None, namespace='main'):
context_instance = Context(dictionary) context_instance = Context(dictionary)
...@@ -27,6 +47,7 @@ def render_to_string(template_name, dictionary, context=None, namespace='main'): ...@@ -27,6 +47,7 @@ def render_to_string(template_name, dictionary, context=None, namespace='main'):
context_dictionary = {} context_dictionary = {}
context_instance['settings'] = settings context_instance['settings'] = settings
context_instance['MITX_ROOT_URL'] = settings.MITX_ROOT_URL 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. # In various testing contexts, there might not be a current request context.
if middleware.requestcontext is not None: if middleware.requestcontext is not None:
......
...@@ -326,11 +326,7 @@ ...@@ -326,11 +326,7 @@
% else: % else:
<section class="empty-dashboard-message"> <section class="empty-dashboard-message">
<p>Looks like you haven't registered for any courses yet.</p> <p>Looks like you haven't registered for any courses yet.</p>
% if settings.MITX_FEATURES.get('ENABLE_MKTG_SITE'): <a href="${marketing_link('COURSES')}">
<a href="${settings.MKTG_URLS.get('ROOT')}${settings.MKTG_URLS.get('COURSES')}">
%else:
<a href="${reverse('courses')}">
%endif
Find courses now! Find courses now!
</a> </a>
</section> </section>
......
...@@ -8,45 +8,25 @@ ...@@ -8,45 +8,25 @@
<nav class="nav-colophon"> <nav class="nav-colophon">
<ol> <ol>
<li class="nav-colophon-01"> <li class="nav-colophon-01">
% if settings.MITX_FEATURES.get('ENABLE_MKTG_SITE'): <a href="${marketing_link('ABOUT')}">
<a href="${settings.MKTG_URLS.get('ROOT')}${settings.MKTG_URLS.get('ABOUT')}">
%else:
<a href="${reverse('about_edx')}">
%endif
About About
</a> </a>
</li> </li>
<li class="nav-colophon-02"> <li class="nav-colophon-02">
% if settings.MITX_FEATURES.get('ENABLE_MKTG_SITE'): <a href="${marketing_link('JOBS')}">
<a href="${settings.MKTG_URLS.get('ROOT')}${settings.MKTG_URLS.get('JOBS')}">
%else:
<a href="${reverse('jobs')}">
%endif
Jobs</a> Jobs</a>
</li> </li>
<li class="nav-colophon-03"> <li class="nav-colophon-03">
% if settings.MITX_FEATURES.get('ENABLE_MKTG_SITE'): <a href="${marketing_link('PRESS')}">
<a href="${settings.MKTG_URLS.get('ROOT')}${settings.MKTG_URLS.get('PRESS')}">
%else:
<a href="${reverse('press')}">
%endif
Press</a> Press</a>
</li> </li>
<li class="nav-colophon-04"> <li class="nav-colophon-04">
% if settings.MITX_FEATURES.get('ENABLE_MKTG_SITE'): <a href="${marketing_link('FAQ')}">
<a href="${settings.MKTG_URLS.get('ROOT')}${settings.MKTG_URLS.get('FAQ')}">
%else:
<a href="${reverse('help_edx')}">
%endif
FAQ FAQ
</a> </a>
</li> </li>
<li class="nav-colophon-05"> <li class="nav-colophon-05">
% if settings.MITX_FEATURES.get('ENABLE_MKTG_SITE'): <a href="${marketing_link('CONTACT')}">
<a href="${settings.MKTG_URLS.get('ROOT')}${settings.MKTG_URLS.get('CONTACT')}">
%else:
<a href="${reverse('contact')}">
%endif
Contact Contact
</a> </a>
</li> </li>
......
...@@ -151,11 +151,7 @@ ...@@ -151,11 +151,7 @@
<h3>Need Help?</h3> <h3>Need Help?</h3>
<p>Looking for help in logging in or with your edX account? <p>Looking for help in logging in or with your edX account?
% if settings.MITX_FEATURES.get('ENABLE_MKTG_SITE'): <a href="${marketing_link('FAQ')}">
<a href="${settings.MKTG_URLS.get('ROOT')}${settings.MKTG_URLS.get('FAQ')}">
%else:
<a href="${reverse('help_edx')}">
%endif
View our help section for answers to commonly asked questions. View our help section for answers to commonly asked questions.
</a></p> </a></p>
......
...@@ -56,11 +56,7 @@ site_status_msg = get_site_status_msg(course_id) ...@@ -56,11 +56,7 @@ site_status_msg = get_site_status_msg(course_id)
<ol class="left nav-global authenticated"> <ol class="left nav-global authenticated">
<li class="nav-global-01"> <li class="nav-global-01">
% if settings.MITX_FEATURES.get('ENABLE_MKTG_SITE'): <a href="${marketing_link('COURSES')}">Find Courses</a>
<a href="${settings.MKTG_URLS.get('ROOT')}${settings.MKTG_URLS.get('COURSES')}">Find Courses</a>
% else:
<a href="${reverse('courses')}">Find Courses</a>
% endif
</li> </li>
</ol> </ol>
<ol class="user"> <ol class="user">
...@@ -74,11 +70,7 @@ site_status_msg = get_site_status_msg(course_id) ...@@ -74,11 +70,7 @@ site_status_msg = get_site_status_msg(course_id)
<a href="#" class="dropdown">&#9662</a> <a href="#" class="dropdown">&#9662</a>
<ul class="dropdown-menu"> <ul class="dropdown-menu">
<li> <li>
% if settings.MITX_FEATURES.get('ENABLE_MKTG_SITE'): <a href="${marketing_link('FAQ')}">
<a href="${settings.MKTG_URLS.get('ROOT')}${settings.MKTG_URLS.get('FAQ')}">
%else:
<a href="${reverse('help_edx')}">
%endif
Help Help
</a></li> </a></li>
<li><a href="${reverse('logout')}">Log Out</a></li> <li><a href="${reverse('logout')}">Log Out</a></li>
...@@ -90,13 +82,13 @@ site_status_msg = get_site_status_msg(course_id) ...@@ -90,13 +82,13 @@ site_status_msg = get_site_status_msg(course_id)
<ol class="left nav-global"> <ol class="left nav-global">
% if settings.MITX_FEATURES.get('ENABLE_MKTG_SITE'): % if settings.MITX_FEATURES.get('ENABLE_MKTG_SITE'):
<li class="nav-global-01"> <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>
<li class="nav-global-02"> <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>
<li class="nav-global-03"> <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> </li>
% endif % endif
% if not settings.MITX_FEATURES['DISABLE_LOGIN_BUTTON']: % if not settings.MITX_FEATURES['DISABLE_LOGIN_BUTTON']:
......
...@@ -237,11 +237,7 @@ ...@@ -237,11 +237,7 @@
<div class="cta cta-help"> <div class="cta cta-help">
<h3>Need Help?</h3> <h3>Need Help?</h3>
<p>Need help in registering with edX? <p>Need help in registering with edX?
% if settings.MITX_FEATURES.get('ENABLE_MKTG_SITE'): <a href="${marketing_link('FAQ')}">
<a href="${settings.MKTG_URLS.get('ROOT')}${settings.MKTG_URLS.get('FAQ')}">
%else:
<a href="${reverse('help_edx')}">
%endif
View our FAQs for answers to commonly asked questions. 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> </a>. Once registered, most questions can be answered in the course specific discussion forums or through the FAQs.</p>
</div> </div>
......
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