From 2bee02a10a4589d59dd2ac996da25450a9720cfb Mon Sep 17 00:00:00 2001 From: Brian Jacobel Date: Mon, 11 Apr 2016 11:14:51 -0400 Subject: [PATCH 01/13] Fix gettext errors by including /js/i18n/LANGUAGE_CODE/djangojs.js in Django template --- lms/templates/main_django.html | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lms/templates/main_django.html b/lms/templates/main_django.html index 80dafdf974..f39e10cd8e 100644 --- a/lms/templates/main_django.html +++ b/lms/templates/main_django.html @@ -1,12 +1,16 @@ -{% load sekizai_tags i18n microsite pipeline optional_include %} +{% load sekizai_tags i18n microsite pipeline optional_include staticfiles %} {% load url from future %} {% block title %}{% platform_name %}{% endblock %} - + + + {% with "js/i18n/"|add:LANGUAGE_CODE|add:"/djangojs.js" as i18njs_path %} + + {% endwith %} {% stylesheet 'style-vendor' %} {% stylesheet 'style-main-v1' %} From ae49f7a6d99dedb0ca414a186999fcb7febed678 Mon Sep 17 00:00:00 2001 From: Brian Jacobel Date: Mon, 11 Apr 2016 11:58:58 -0400 Subject: [PATCH 02/13] Fix a usage of a Mako thing that doesn't work here --- lms/templates/main_django.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lms/templates/main_django.html b/lms/templates/main_django.html index f39e10cd8e..296fe5777e 100644 --- a/lms/templates/main_django.html +++ b/lms/templates/main_django.html @@ -27,7 +27,7 @@ -
+
{% trans "Skip to main content" %} {% with course=request.course %} {% include "header.html"|microsite_template_path %} From bceab97d775a8ef5f1164a80d539dd9037569602 Mon Sep 17 00:00:00 2001 From: Brian Jacobel Date: Mon, 11 Apr 2016 12:49:36 -0400 Subject: [PATCH 03/13] The only JS the pages using this template need is base_application --- lms/templates/main_django.html | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lms/templates/main_django.html b/lms/templates/main_django.html index 296fe5777e..e2d5233ba9 100644 --- a/lms/templates/main_django.html +++ b/lms/templates/main_django.html @@ -42,8 +42,7 @@
- {% javascript 'application' %} - {% javascript 'module-js' %} + {% javascript 'base_application' %} {% render_block "js" %} From 5965091a8966157133e0154849868e5a5dc9949c Mon Sep 17 00:00:00 2001 From: Brian Jacobel Date: Mon, 11 Apr 2016 13:20:58 -0400 Subject: [PATCH 04/13] Remove an old i18n JS include from the wiki that did nothing --- lms/templates/wiki/base.html | 1 - 1 file changed, 1 deletion(-) diff --git a/lms/templates/wiki/base.html b/lms/templates/wiki/base.html index c8f5eadf29..2a9c69fed9 100644 --- a/lms/templates/wiki/base.html +++ b/lms/templates/wiki/base.html @@ -6,7 +6,6 @@ {% block bodyclass %}view-in-course view-wiki{% endblock %} {% block headextra %} - {% stylesheet 'course' %} {% stylesheet 'style-course-vendor' %} {% stylesheet 'style-course' %} From bda18f46c083085aba958569713f96438437dc21 Mon Sep 17 00:00:00 2001 From: Brian Jacobel Date: Mon, 11 Apr 2016 14:41:34 -0400 Subject: [PATCH 05/13] Convert password_reset_confirm.html to Mako --- .../registration/password_reset_confirm.html | 75 ++++++++++--------- 1 file changed, 39 insertions(+), 36 deletions(-) diff --git a/lms/templates/registration/password_reset_confirm.html b/lms/templates/registration/password_reset_confirm.html index cddebf7854..a9c6ae64b0 100644 --- a/lms/templates/registration/password_reset_confirm.html +++ b/lms/templates/registration/password_reset_confirm.html @@ -1,72 +1,75 @@ -{% extends "main_django.html" %} -{% load i18n %} +## mako -{% block title %} - -{% blocktrans with platform_name=platform_name %} - Reset Your {{ platform_name }} Password -{% endblocktrans %} - -{% endblock %} +<%! from django.utils.translation import ugettext as _ %> -{% block bodyextra %} - -{% endblock %} +<%inherit file="../main.html"/> -{% block bodyclass %}view-passwordreset{% endblock %} +<%block name="title"> + ${_("Reset Your {platform_name} Password".format(platform_name=platform_name))} + -{% block body %} +<%block name="bodyextra"> + + + +<%block name="bodyclass">view-passwordreset + +<%block name="body"> -{% endblock %} + From 422147ea5a05090fc545c84ce03b13229969def3 Mon Sep 17 00:00:00 2001 From: Brian Jacobel Date: Mon, 11 Apr 2016 16:17:18 -0400 Subject: [PATCH 06/13] Migrate password_reset_confirm.html to Mako (2/4) --- .../registration/password_reset_complete.html | 32 +++++++++++-------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/lms/templates/registration/password_reset_complete.html b/lms/templates/registration/password_reset_complete.html index 702aa7b134..16d990431c 100644 --- a/lms/templates/registration/password_reset_complete.html +++ b/lms/templates/registration/password_reset_complete.html @@ -1,11 +1,14 @@ -{% extends "main_django.html" %} -{% load i18n %} +## mako -{% block title %} -{% trans "Your Password Reset is Complete" %} -{% endblock %} +<%! from django.utils.translation import ugettext as _ %> -{% block bodyextra %} +<%inherit file="../main.html"/> + +<%block name="title"> + ${_("Your Password Reset is Complete")} + + +<%block name="bodyextra"> -{% endblock %} + -{% block bodyclass %}view-passwordreset{% endblock %} +<%block name="bodyclass">view-passwordreset -{% block body %} +<%block name="body"> -{% endblock %} + From 784e200a2fb9e80673aa668cd31f0189b5c578c4 Mon Sep 17 00:00:00 2001 From: Brian Jacobel Date: Tue, 12 Apr 2016 15:01:41 -0400 Subject: [PATCH 07/13] OAuth grant screen converted to mako (3/4) --- lms/templates/provider/authorize.html | 81 +++++++++++++++------------ 1 file changed, 44 insertions(+), 37 deletions(-) diff --git a/lms/templates/provider/authorize.html b/lms/templates/provider/authorize.html index f3f34b08ed..e3867b036f 100644 --- a/lms/templates/provider/authorize.html +++ b/lms/templates/provider/authorize.html @@ -1,59 +1,66 @@ -{% extends "main_django.html" %} +## mako -{% load scope i18n %} +<%! +from django.utils.translation import ugettext as _ +from provider.templatetags.scope import scopes +from django.core.urlresolvers import reverse +%> -{% block bodyclass %}oauth2{% endblock %} +<%inherit file="../main.html"/> -{% block body %} +<%block name="bodyclass">oauth2 + +<%block name="body">
- {% if not error %} + % if not error:

- {% blocktrans with application_name=client.name %} - {{ application_name }} would like to access your data with the following permissions: - {% endblocktrans %} + ${_( + "{application_name} would like to access your data with the following permissions:" + .format(application_name=client.name) + )}

    - {% for permission in oauth_data.scope|scopes %} + % for permission in scopes(oauth_data['scope']):
  • - {% if permission == "openid" %} - {% trans "Read your user ID" %} - {% elif permission == "profile" %} - {% trans "Read your user profile" %} - {% elif permission == "email" %} - {% trans "Read your email address" %} - {% elif permission == "course_staff" %} - {% trans "Read the list of courses in which you are a staff member." %} - {% elif permission == "course_instructor" %} - {% trans "Read the list of courses in which you are an instructor." %} - {% elif permission == "permissions" %} - {% trans "To see if you are a global staff user" %} - {% else %} - {% blocktrans %}Manage your data: {{ permission }}{% endblocktrans %} - {% endif %} + % if permission == "openid": + ${_("Read your user ID")} + % elif permission == "profile": + ${_("Read your user profile")} + % elif permission == "email": + ${_("Read your email address")} + % elif permission == "course_staff": + ${_("Read the list of courses in which you are a staff member.")} + % elif permission == "course_instructor": + ${_("Read the list of courses in which you are an instructor.")} + % elif permission == "permissions": + ${_("To see if you are a global staff user")} + % else: + ${_("Manage your data: {permission}".format(permission=permission))} + % endif
  • - {% endfor %} + % endfor
-
- {% csrf_token %} - {{ form.errors }} - {{ form.non_field_errors }} + + ${form.errors} + ${form.non_field_errors()}
+
- {% else %} + % else:

- {{ error }} - {{ error_description }} + ${error} + ${error_description}

- {% endif %} + % endif
-{% endblock %} + From 284cc17b1d8e6cf6bbc6737ec8cf44bc8441093a Mon Sep 17 00:00:00 2001 From: Brian Jacobel Date: Tue, 12 Apr 2016 17:15:05 -0400 Subject: [PATCH 08/13] Move manual refunds page to Mako --- lms/templates/support/refund.html | 62 +++++++++++++++++-------------- 1 file changed, 35 insertions(+), 27 deletions(-) diff --git a/lms/templates/support/refund.html b/lms/templates/support/refund.html index b42494f9fd..c224c21fcd 100644 --- a/lms/templates/support/refund.html +++ b/lms/templates/support/refund.html @@ -1,11 +1,18 @@ -{% extends "main_django.html" %} -{% load i18n %} -{% block title %} +## mako + +<%! +from django.utils.translation import ugettext as _ +from django.utils.html import escape +%> + +<%inherit file="../main.html"/> + +<%block name="title"> Manual Refund -{% endblock %} -{% block headextra %} + +<%block name="headextra"> -{% endblock %} + -{% block body %} +<%block name="body">
-

{% trans "Manual Refund" %}

- {% if messages %} +

${_("Manual Refund")}

+ % if messages:
    - {% for message in messages %} - {{ message }} - {% endfor %} + % for message in messages: +
  • ${message}
  • + % endfor
- {% endif %} + % endif
- {% csrf_token %} - {{form.as_p}} + + ${form.as_p()}

- +

- {% if cert %} + % if cert:

- {% trans "About to refund this order:" %} + ${_("About to refund this order:")}

- {% trans "Order Id:" %} {{cert.order.id}} + ${_("Order Id:")} ${cert.order.id}

- {% trans "Enrollment:" %} {{enrollment.course_id|escape}} {{enrollment.mode}} ({% if enrollment.is_active %}{% trans "enrolled" %}{% else %}{% trans "unenrolled" %}{% endif %}) + ${_("Enrollment:")} ${escape(enrollment.course_id)} ${enrollment.mode} + (${_("enrolled") if enrollment.is_active else _("unenrolled")})

- {% trans "Cost:" %} {{cert.unit_cost}} {{cert.currency}} + ${_("Cost:")} ${cert.unit_cost} ${cert.currency}

- {% trans "CertificateItem Status:" %} {{cert.status}} + ${_("CertificateItem Status:")} ${cert.status}

- {% trans "Order Status:" %} {{cert.order.status}} + ${_("Order Status:")} ${cert.order.status}

- {% trans "Fulfilled Time:" %} {{cert.fulfilled_time}} + ${_("Fulfilled Time:")} ${cert.fulfilled_time}

- {% trans "Refund Request Time:" %} {{cert.refund_requested_time}} + ${_("Refund Request Time:")} ${cert.refund_requested_time}

- {% endif %} + % endif
-{% endblock %} + From e5767336081f387633590375c9e77d10fdf80df0 Mon Sep 17 00:00:00 2001 From: Brian Jacobel Date: Thu, 14 Apr 2016 17:29:17 -0400 Subject: [PATCH 09/13] Mako templates return context in .context_data rather than .context --- lms/djangoapps/oauth_dispatch/tests/test_views.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lms/djangoapps/oauth_dispatch/tests/test_views.py b/lms/djangoapps/oauth_dispatch/tests/test_views.py index b8fb7435ff..b811d83ff1 100644 --- a/lms/djangoapps/oauth_dispatch/tests/test_views.py +++ b/lms/djangoapps/oauth_dispatch/tests/test_views.py @@ -166,7 +166,7 @@ class TestAuthorizationView(TestCase): self.assertEqual(response.status_code, 200) # check form is in context and form params are valid - context = response.context # pylint: disable=no-member + context = response.context_data # pylint: disable=no-member self.assertIn('form', context) self.assertIsNone(context['form']['authorize'].value()) From 3c944d2af3ee74acf5219169f152ef1941f7c5b3 Mon Sep 17 00:00:00 2001 From: Brian Jacobel Date: Tue, 19 Apr 2016 12:41:08 -0400 Subject: [PATCH 10/13] Fix line wrapping here --- lms/templates/provider/authorize.html | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/lms/templates/provider/authorize.html b/lms/templates/provider/authorize.html index e3867b036f..eceee2519a 100644 --- a/lms/templates/provider/authorize.html +++ b/lms/templates/provider/authorize.html @@ -14,10 +14,9 @@ from django.core.urlresolvers import reverse
% if not error:

- ${_( - "{application_name} would like to access your data with the following permissions:" - .format(application_name=client.name) - )} + ${_("{application_name} would like to access your data with the following permissions:".format( + application_name=client.name + ))}

    % for permission in scopes(oauth_data['scope']): From ac37c12b7dca9e946c9d09bb0f068b5ecb0e1e94 Mon Sep 17 00:00:00 2001 From: Brian Jacobel Date: Wed, 20 Apr 2016 15:27:30 -0400 Subject: [PATCH 11/13] This is what this string used to look like, to gettext --- lms/templates/provider/authorize.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lms/templates/provider/authorize.html b/lms/templates/provider/authorize.html index eceee2519a..f3ab459b67 100644 --- a/lms/templates/provider/authorize.html +++ b/lms/templates/provider/authorize.html @@ -14,7 +14,7 @@ from django.core.urlresolvers import reverse
    % if not error:

    - ${_("{application_name} would like to access your data with the following permissions:".format( + ${_("\n {application_name} would like to access your data with the following permissions:\n ".format( application_name=client.name ))}

    From 060b5bf97d61cd803777ecddfb12f01e5918b933 Mon Sep 17 00:00:00 2001 From: Brian Jacobel Date: Fri, 22 Apr 2016 16:45:45 -0400 Subject: [PATCH 12/13] Update escaping and safe-templating usage --- lms/templates/provider/authorize.html | 13 ++++++---- .../registration/password_reset_complete.html | 13 ++++++---- .../registration/password_reset_confirm.html | 24 +++++++++++++------ lms/templates/support/refund.html | 2 ++ 4 files changed, 37 insertions(+), 15 deletions(-) diff --git a/lms/templates/provider/authorize.html b/lms/templates/provider/authorize.html index f3ab459b67..6181de9725 100644 --- a/lms/templates/provider/authorize.html +++ b/lms/templates/provider/authorize.html @@ -1,9 +1,12 @@ ## mako +<%page expression_filter="h"/> + <%! from django.utils.translation import ugettext as _ from provider.templatetags.scope import scopes from django.core.urlresolvers import reverse +from openedx.core.djangolib.markup import Text, HTML %> <%inherit file="../main.html"/> @@ -14,9 +17,11 @@ from django.core.urlresolvers import reverse
    % if not error:

    - ${_("\n {application_name} would like to access your data with the following permissions:\n ".format( - application_name=client.name - ))} + ${Text(_("{start_strong}{application_name}{end_strong} would like to access your data with the following permissions:")).format( + start_strong=HTML(""), + application_name=client.name, + end_strong=HTML("") + )}

      % for permission in scopes(oauth_data['scope']): @@ -34,7 +39,7 @@ from django.core.urlresolvers import reverse % elif permission == "permissions": ${_("To see if you are a global staff user")} % else: - ${_("Manage your data: {permission}".format(permission=permission))} + ${_("Manage your data: {permission}").format(permission=permission)} % endif % endfor diff --git a/lms/templates/registration/password_reset_complete.html b/lms/templates/registration/password_reset_complete.html index 16d990431c..af83c40e1b 100644 --- a/lms/templates/registration/password_reset_complete.html +++ b/lms/templates/registration/password_reset_complete.html @@ -1,6 +1,11 @@ ## mako -<%! from django.utils.translation import ugettext as _ %> +<%page expression_filter="h"/> + +<%! +from django.utils.translation import ugettext as _ +from openedx.core.djangolib.markup import Text, HTML +%> <%inherit file="../main.html"/> @@ -27,9 +32,9 @@

      ${_("Password Reset Complete")}

        - ${_( - "Your password has been reset. {start_link}Sign-in to your account.{end_link}" - .format(start_link='', end_link='') + ${Text(_("Your password has been reset. {start_link}Sign-in to your account.{end_link}")).format( + start_link=HTML(''), + end_link=HTML('') )}
      diff --git a/lms/templates/registration/password_reset_confirm.html b/lms/templates/registration/password_reset_confirm.html index a9c6ae64b0..e28d16ecf0 100644 --- a/lms/templates/registration/password_reset_confirm.html +++ b/lms/templates/registration/password_reset_confirm.html @@ -1,11 +1,16 @@ ## mako -<%! from django.utils.translation import ugettext as _ %> +<%page expression_filter="h"/> + +<%! +from django.utils.translation import ugettext as _ +from openedx.core.djangolib.markup import Text, HTML +%> <%inherit file="../main.html"/> <%block name="title"> - ${_("Reset Your {platform_name} Password".format(platform_name=platform_name))} + ${_("Reset Your {platform_name} Password").format(platform_name=platform_name)} <%block name="bodyextra"> @@ -18,7 +23,7 @@