From 4d323271ee04fd505f2c2e2fb8d989c36245a10c Mon Sep 17 00:00:00 2001 From: David Baumgold Date: Mon, 12 Jan 2015 15:44:21 -0500 Subject: [PATCH] Make Tender optional and configurable --- cms/envs/common.py | 5 +++ cms/envs/test.py | 2 ++ cms/static/coffee/spec/main.coffee | 2 +- cms/static/coffee/spec/main_squire.coffee | 2 +- cms/static/require-config.js | 4 ++- cms/templates/activation_invalid.html | 6 +++- cms/templates/base.html | 10 ++++-- cms/templates/error.html | 22 ++++++++++--- cms/templates/index.html | 38 +++++++++++++++++------ cms/templates/login.html | 19 +++++++----- cms/templates/widgets/footer.html | 4 +-- cms/templates/widgets/sock.html | 15 ++++++--- cms/templates/widgets/tender.html | 2 +- lms/static/js/spec/main.js | 2 +- 14 files changed, 96 insertions(+), 37 deletions(-) diff --git a/cms/envs/common.py b/cms/envs/common.py index a3e1e95034..ec64fa3c8f 100644 --- a/cms/envs/common.py +++ b/cms/envs/common.py @@ -502,6 +502,11 @@ REQUIRE_EXCLUDE = ("build.txt",) # It can also be a path to a custom class that subclasses require.environments.Environment and defines some "args" function that returns a list with the command arguments to execute. REQUIRE_ENVIRONMENT = "node" +# If you want to enable Tender integration (http://tenderapp.com/), +# put in the domain where Tender hosts tender_widget.js. For example, +# TENDER_DOMAIN = "example.tenderapp.com" +TENDER_DOMAIN = None + ################################# CELERY ###################################### # Message configuration diff --git a/cms/envs/test.py b/cms/envs/test.py index 2d16ded81a..d88071ccd6 100644 --- a/cms/envs/test.py +++ b/cms/envs/test.py @@ -74,6 +74,8 @@ STATICFILES_STORAGE = 'pipeline.storage.NonPackagingPipelineStorage' STATIC_URL = "/static/" PIPELINE_ENABLED = False +TENDER_DOMAIN = "help.edge.edx.org" + # Update module store settings per defaults for tests update_module_store_settings( MODULESTORE, diff --git a/cms/static/coffee/spec/main.coffee b/cms/static/coffee/spec/main.coffee index 3a7b2c046a..6054189275 100644 --- a/cms/static/coffee/spec/main.coffee +++ b/cms/static/coffee/spec/main.coffee @@ -49,7 +49,7 @@ requirejs.config({ "mathjax": "//cdn.mathjax.org/mathjax/2.2-latest/MathJax.js?config=TeX-MML-AM_HTMLorMML-full&delayStartupUntil=configured", "youtube": "//www.youtube.com/player_api?noext", - "tender": "//edxedge.tenderapp.com/tender_widget", + "tender": "//api.tenderapp.com/tender_widget", "coffee/src/ajax_prefix": "xmodule_js/common_static/coffee/src/ajax_prefix", "js/spec/test_utils": "js/spec/test_utils", diff --git a/cms/static/coffee/spec/main_squire.coffee b/cms/static/coffee/spec/main_squire.coffee index 24d855a75d..db206deab8 100644 --- a/cms/static/coffee/spec/main_squire.coffee +++ b/cms/static/coffee/spec/main_squire.coffee @@ -43,7 +43,7 @@ requirejs.config({ "mathjax": "//cdn.mathjax.org/mathjax/2.2-latest/MathJax.js?config=TeX-MML-AM_HTMLorMML-full&delayStartupUntil=configured", "youtube": "//www.youtube.com/player_api?noext", - "tender": "//edxedge.tenderapp.com/tender_widget.js" + "tender": "//api.tenderapp.com/tender_widget.js" "coffee/src/ajax_prefix": "xmodule_js/common_static/coffee/src/ajax_prefix" } diff --git a/cms/static/require-config.js b/cms/static/require-config.js index 0c5646d037..12b139fe93 100644 --- a/cms/static/require-config.js +++ b/cms/static/require-config.js @@ -67,7 +67,9 @@ require.config({ // externally hosted files "tender": [ - "//edxedge.tenderapp.com/tender_widget", + // if TENDER_DOMAIN is defined, use that; otherwise, use a dummy value + // (the application JS will never `require(['tender'])` if it's not defined) + "//" + (typeof TENDER_DOMAIN === "string" ? TENDER_DOMAIN : "api.tenderapp.com") + "/tender_widget", // if tender fails to load, fallback on a local file // so that require doesn't fall over "js/src/tender_fallback" diff --git a/cms/templates/activation_invalid.html b/cms/templates/activation_invalid.html index 585293e75b..b077d64bd7 100644 --- a/cms/templates/activation_invalid.html +++ b/cms/templates/activation_invalid.html @@ -26,9 +26,13 @@ diff --git a/cms/templates/base.html b/cms/templates/base.html index d02d85fb0e..55a66241ad 100644 --- a/cms/templates/base.html +++ b/cms/templates/base.html @@ -1,6 +1,9 @@ ## -*- coding: utf-8 -*- -<%! from django.utils.translation import ugettext as _ %> -<%! from django.template.defaultfilters import escapejs %> +<%! +from django.utils.translation import ugettext as _ +from django.template.defaultfilters import escapejs +import json +%> <%namespace name='static' file='static_content.html'/> @@ -46,7 +49,8 @@ ${_("Skip to this view's content")} diff --git a/cms/templates/error.html b/cms/templates/error.html index 2b183f1c53..01f19e1b32 100644 --- a/cms/templates/error.html +++ b/cms/templates/error.html @@ -10,21 +10,35 @@ % endif +<%! +from django.conf import settings + +if settings.TENDER_DOMAIN: + help_link_start = ''.format( + domain=settings.TENDER_DOMAIN, + title=_("Use our feedback tool, Tender, to share your feedback") + ), + help_link_end = '' +else: + help_link_start = ''.format(email=settings.TECH_SUPPORT_EMAIL) + help_link_end = '' +%> + <%block name="content">
% if error == '404':

${_("The Page You Requested Page Cannot be Found")}

${_("We're sorry. We couldn't find the {studio_name} page you're looking for. You may want to return to the {studio_name} Dashboard and try again. If you are still having problems accessing things, please feel free to {link_start}contact {studio_name} support{link_end} for further help.").format( studio_name=settings.STUDIO_SHORT_NAME, - link_start=''.format(title=_("Use our feedback tool, Tender, to share your feedback")), - link_end='', + link_start=help_link_start, + link_end=help_link_end, )}

% elif error == '500':

${_("The Server Encountered an Error")}

${_("We're sorry. There was a problem with the server while trying to process your last request. You may want to return to the {studio_name} Dashboard or try this request again. If you are still having problems accessing things, please feel free to {link_start}contact {studio_name} support{link_end} for further help.").format( studio_name=settings.STUDIO_SHORT_NAME, - link_start=''.format(title=_("Use our feedback tool, Tender, to share your feedback")), - link_end='', + link_start=help_link_start, + link_end=help_link_end, )}

% endif ${_("Back to dashboard")} diff --git a/cms/templates/index.html b/cms/templates/index.html index f823d6bb39..8c437f6f55 100644 --- a/cms/templates/index.html +++ b/cms/templates/index.html @@ -374,9 +374,13 @@ ${_("Getting Started with {studio_name}").format(studio_name=settings.STUDIO_NAME)} -
  • - ${_("Request help with {studio_name}").format(studio_name=settings.STUDIO_NAME)} -
  • + % if settings.TENDER_DOMAIN: +
  • + + ${_("Request help with {studio_name}").format(studio_name=settings.STUDIO_NAME)} + +
  • + % endif @@ -401,13 +405,23 @@ % elif course_creator_status == "denied":

    ${_("Can I create courses in {studio_name}?").format(studio_name=settings.STUDIO_NAME)}

    +<%! +from django.conf import settings + +if settings.TENDER_DOMAIN: + help_link_start = ''.format( + domain=settings.TENDER_DOMAIN, + ) + help_link_end = '' +else: + help_link_start = ''.format(email=settings.TECH_SUPPORT_EMAIL) + help_link_end = '' +%>

    ${_("Your request to author courses in {studio_name} has been denied. Please {link_start}contact {platform_name} Staff with further questions{link_end}.").format( studio_name=settings.STUDIO_NAME, platform_name=settings.PLATFORM_NAME, - link_start=''.format( - url="http://help.edge.edx.org/discussion/new", - ), - link_end="", + link_start=help_link_start, + link_end=help_link_end, )}

    @@ -439,9 +453,13 @@

    ${_('Please check your Junk or Spam folders in case our email isn\'t in your INBOX. Still can\'t find the verification email? Request help via the link below.')}

      -
    1. - ${_("Request help with your {studio_name} account").format(studio_name=settings.STUDIO_NAME)} -
    2. + % if settings.TENDER_DOMAIN: +
    3. + + ${_("Request help with your {studio_name} account").format(studio_name=settings.STUDIO_NAME)} + +
    4. + % endif
    diff --git a/cms/templates/login.html b/cms/templates/login.html index 14d4be996b..07d2c8d820 100644 --- a/cms/templates/login.html +++ b/cms/templates/login.html @@ -45,14 +45,19 @@ from django.utils.translation import ugettext as _
    - + % endif diff --git a/cms/templates/widgets/footer.html b/cms/templates/widgets/footer.html index 197b20bf8a..dfb4192371 100644 --- a/cms/templates/widgets/footer.html +++ b/cms/templates/widgets/footer.html @@ -15,9 +15,9 @@ - % if user.is_authenticated(): + % if settings.TENDER_DOMAIN and user.is_authenticated(): % endif diff --git a/cms/templates/widgets/sock.html b/cms/templates/widgets/sock.html index c2b44665f9..755d0ca922 100644 --- a/cms/templates/widgets/sock.html +++ b/cms/templates/widgets/sock.html @@ -29,10 +29,13 @@ ${_("Building and Running an {platform_name} Course PDF").format(platform_name=settings.PLATFORM_NAME)} -
  • - ${_("{studio_name} Author Support").format(studio_name=settings.STUDIO_NAME)} - ${_("{studio_name} Author Support").format(studio_name=settings.STUDIO_NAME)} -
  • + % if settings.TENDER_DOMAIN: +
  • + ${_("{studio_name} Author Support").format(studio_name=settings.STUDIO_NAME)} + ${_("{studio_name} Author Support").format(studio_name=settings.STUDIO_NAME)} +
  • + % endif +
  • ${_("Enroll in edX101")} ${_("How to use {studio_name} to build your course").format(studio_name=settings.STUDIO_NAME)} @@ -40,6 +43,7 @@ + % if settings.TENDER_DOMAIN: + % endif diff --git a/cms/templates/widgets/tender.html b/cms/templates/widgets/tender.html index 4f9b182a28..97fde3c5ab 100644 --- a/cms/templates/widgets/tender.html +++ b/cms/templates/widgets/tender.html @@ -1,4 +1,4 @@ -% if user.is_authenticated(): +% if settings.TENDER_DOMAIN and user.is_authenticated():