Commit 19b92429 by Brian Jacobel

Merge pull request #12151 from edx/bjacobel/requirejs-errors-in-django-templates

Fix errors in old Django templates / migrate to Mako
parents 036537f1 e6875d3f
...@@ -182,7 +182,7 @@ class TestAuthorizationView(TestCase): ...@@ -182,7 +182,7 @@ class TestAuthorizationView(TestCase):
self.assertEqual(response.status_code, 200) self.assertEqual(response.status_code, 200)
# check form is in context and form params are valid # 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.assertIn('form', context)
self.assertIsNone(context['form']['authorize'].value()) self.assertIsNone(context['form']['authorize'].value())
......
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
@include span-columns(6); @include span-columns(6);
@include shift(3); @include shift(3);
float: unset !important; // fixes issues with oauth page and edx-theme footer
line-height: 1.5em; line-height: 1.5em;
padding: 50px 0; padding: 50px 0;
......
<!DOCTYPE html> <!DOCTYPE html>
{% load sekizai_tags i18n microsite pipeline optional_include %} {% load sekizai_tags i18n microsite pipeline optional_include staticfiles %}
{% load url from future %} {% load url from future %}
<html lang="{{LANGUAGE_CODE}}"> <html lang="{{LANGUAGE_CODE}}">
<head> <head>
<meta charset="UTF-8"> <meta charset="UTF-8">
{% block title %}<title>{% platform_name %}</title>{% endblock %} {% block title %}<title>{% platform_name %}</title>{% endblock %}
<link rel="icon" type="image/x-icon" href="{% favicon_path %}" /> <link rel="icon" type="image/x-icon" href="{% favicon_path %}" />
{% with "js/i18n/"|add:LANGUAGE_CODE|add:"/djangojs.js" as i18njs_path %}
<script type="text/javascript" src="{% static i18njs_path %}"></script>
{% endwith %}
{% stylesheet 'style-vendor' %} {% stylesheet 'style-vendor' %}
{% stylesheet 'style-main-v1' %} {% stylesheet 'style-main-v1' %}
...@@ -23,7 +27,7 @@ ...@@ -23,7 +27,7 @@
</head> </head>
<body class="{% block bodyclass %}{% endblock %} lang_{{LANGUAGE_CODE}}"> <body class="{% block bodyclass %}{% endblock %} lang_{{LANGUAGE_CODE}}">
<div class="window-wrap" dir="${static.dir_rtl()}"> <div class="window-wrap" dir="{{LANGUAGE_BIDI|yesno:'rtl,ltr'}}">
<a class="nav-skip" href="#main">{% trans "Skip to main content" %}</a> <a class="nav-skip" href="#main">{% trans "Skip to main content" %}</a>
{% with course=request.course %} {% with course=request.course %}
{% include "header.html"|microsite_template_path %} {% include "header.html"|microsite_template_path %}
...@@ -38,8 +42,7 @@ ...@@ -38,8 +42,7 @@
</div> </div>
{% javascript 'application' %} {% javascript 'base_application' %}
{% javascript 'module-js' %}
{% render_block "js" %} {% render_block "js" %}
</body> </body>
......
{% extends "main_django.html" %} ## mako
{% load scope i18n %} <%page expression_filter="h"/>
{% block bodyclass %}oauth2{% endblock %} <%!
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
%>
{% block body %} <%inherit file="../main.html"/>
<%block name="bodyclass">oauth2</%block>
<%block name="body">
<div class="authorization-confirmation"> <div class="authorization-confirmation">
{% if not error %} % if not error:
<p> <p>
{% blocktrans with application_name=client.name %} ${Text(_("{start_strong}{application_name}{end_strong} would like to access your data with the following permissions:")).format(
<strong>{{ application_name }}</strong> would like to access your data with the following permissions: start_strong=HTML("<strong>"),
{% endblocktrans %} application_name=client.name,
end_strong=HTML("</strong>")
)}
</p> </p>
<ul> <ul>
{% for permission in oauth_data.scope|scopes %} % for permission in scopes(oauth_data['scope']):
<li> <li>
{% if permission == "openid" %} % if permission == "openid":
{% trans "Read your user ID" %} ${_("Read your user ID")}
{% elif permission == "profile" %} % elif permission == "profile":
{% trans "Read your user profile" %} ${_("Read your user profile")}
{% elif permission == "email" %} % elif permission == "email":
{% trans "Read your email address" %} ${_("Read your email address")}
{% elif permission == "course_staff" %} % elif permission == "course_staff":
{% trans "Read the list of courses in which you are a staff member." %} ${_("Read the list of courses in which you are a staff member.")}
{% elif permission == "course_instructor" %} % elif permission == "course_instructor":
{% trans "Read the list of courses in which you are an instructor." %} ${_("Read the list of courses in which you are an instructor.")}
{% elif permission == "permissions" %} % elif permission == "permissions":
{% trans "To see if you are a global staff user" %} ${_("To see if you are a global staff user")}
{% else %} % else:
{% blocktrans %}Manage your data: {{ permission }}{% endblocktrans %} ${_("Manage your data: {permission}").format(permission=permission)}
{% endif %} % endif
</li> </li>
{% endfor %} % endfor
</ul> </ul>
<form method="post" action="{% url "oauth2:authorize" %}"> <form method="post" action="${reverse('oauth2:authorize')}">
{% csrf_token %} ${form.errors}
{{ form.errors }} ${form.non_field_errors()}
{{ form.non_field_errors }}
<fieldset> <fieldset>
<div style="display: none;"> <div style="display: none;">
<select type="select" name="scope" multiple="multiple"> <select type="select" name="scope" multiple="multiple">
{% for scope in oauth_data.scope|scopes %} % for scope in scopes(oauth_data['scope']):
<option value="{{ scope }}" selected="selected">{{ scope }}</option> <option value="${scope}" selected="selected">${scope}</option>
{% endfor %} % endfor
</select> </select>
</div> </div>
<input type="submit" class="btn login large danger" name="cancel" value="Cancel" /> <input type="submit" class="btn login large danger" name="cancel" value="Cancel" />
<input type="submit" class="btn login large primary" name="authorize" value="Authorize" /> <input type="submit" class="btn login large primary" name="authorize" value="Authorize" />
</fieldset> </fieldset>
<input type="hidden" id="csrf_token" name="csrfmiddlewaretoken" value="${csrf_token}" />
</form> </form>
{% else %} % else:
<p class="error"> <p class="error">
{{ error }} ${error}
{{ error_description }} ${error_description}
</p> </p>
{% endif %} % endif
</div> </div>
{% endblock %} </%block>
{% extends "main_django.html" %} ## mako
{% load i18n %}
{% block title %} <%page expression_filter="h"/>
<title>{% trans "Your Password Reset is Complete" %}</title>
{% endblock %}
{% block bodyextra %} <%!
from django.utils.translation import ugettext as _
from openedx.core.djangolib.markup import Text, HTML
%>
<%inherit file="../main.html"/>
<%block name="title">
<title>${_("Your Password Reset is Complete")}</title>
</%block>
<%block name="bodyextra">
<script type="text/javascript"> <script type="text/javascript">
$(function() { $(function() {
'use strict'; 'use strict';
...@@ -13,23 +21,24 @@ ...@@ -13,23 +21,24 @@
$('body').addClass('js'); $('body').addClass('js');
}); });
</script> </script>
{% endblock %} </%block>
{% block bodyclass %}view-passwordreset{% endblock %} <%block name="bodyclass">view-passwordreset</%block>
{% block body %} <%block name="body">
<div id="password-reset-complete-container" class="login-register"> <div id="password-reset-complete-container" class="login-register">
<section id="password-reset-complete-anchor" class="form-type"> <section id="password-reset-complete-anchor" class="form-type">
<div id="password-reset-complete" class="form-wrapper"> <div id="password-reset-complete" class="form-wrapper">
<div class="status submission-success" aria-live="polite"> <div class="status submission-success" aria-live="polite">
<h4 class="message-title">{% trans "Password Reset Complete" %}</h4> <h4 class="message-title">${_("Password Reset Complete")}</h4>
<ul class="message-copy"> <ul class="message-copy">
{% blocktrans with link_start='<a href="/login">' link_end='</a>' %} ${Text(_("Your password has been reset. {start_link}Sign-in to your account.{end_link}")).format(
Your password has been reset. {{ link_start }}Sign in to your account.{{ link_end }} start_link=HTML('<a href="/login">'),
{% endblocktrans %} end_link=HTML('</a>')
)}
</ul> </ul>
</div> </div>
</div> </div>
</section> </section>
</div> </div>
{% endblock %} </%block>
{% extends "main_django.html" %} ## mako
{% load i18n %}
{% block title %} <%page expression_filter="h"/>
<title>
{% blocktrans with platform_name=platform_name %}
Reset Your {{ platform_name }} Password
{% endblocktrans %}
</title>
{% endblock %}
{% block bodyextra %} <%!
<script type="text/javascript" src="{{STATIC_URL}}js/student_account/password_reset.js"></script> from django.utils.translation import ugettext as _
{% endblock %} from openedx.core.djangolib.markup import Text, HTML
%>
{% block bodyclass %}view-passwordreset{% endblock %} <%inherit file="../main.html"/>
{% block body %} <%block name="title">
<title>${_("Reset Your {platform_name} Password").format(platform_name=platform_name)}</title>
</%block>
<%block name="bodyextra">
<script type="text/javascript" src="${STATIC_URL}js/student_account/password_reset.js"></script>
</%block>
<%block name="bodyclass">view-passwordreset</%block>
<%block name="body">
<div id="password-reset-confirm-container" class="login-register"> <div id="password-reset-confirm-container" class="login-register">
<section id="password-reset-confirm-anchor" class="form-type"> <section id="password-reset-confirm-anchor" class="form-type">
<div id="password-reset-confirm-form" class="form-wrapper" aria-live="polite"> <div id="password-reset-confirm-form" class="form-wrapper" aria-live="polite">
<div class="status submission-error {% if not err_msg %} hidden {% endif %}"> <div class="status submission-error ${'hidden' if not err_msg else ''}">
<h4 class="message-title">{% trans "Error Resetting Password" %}</h4> <h4 class="message-title">${_("Error Resetting Password")}</h4>
<ul class="message-copy"> <ul class="message-copy">
{% if err_msg %} % if err_msg:
<li>{{err_msg}}</li> <li>${err_msg}</li>
{% else %} % else:
<li>{% trans "You must enter and confirm your new password." %}</li> <li>${_("You must enter and confirm your new password.")}</li>
<li>{% trans "The text in both password fields must match." %}</li> <li>${_("The text in both password fields must match.")}</li>
{% endif %} % endif
</ul> </ul>
</div> </div>
{% if validlink %}
<form role="form" id="passwordreset-form" method="post" action="">{% csrf_token %} % if validlink:
<form role="form" id="passwordreset-form" method="post" action="">
<div class="section-title lines"> <div class="section-title lines">
<h2> <h2>
<span class="text"> <span class="text">
{% trans "Reset Your Password" %} ${_("Reset Your Password")}
</span> </span>
</h2> </h2>
</div> </div>
<p class="action-label" id="new_password_help_text"> <p class="action-label" id="new_password_help_text">
{% trans "Enter and confirm your new password." %} ${_("Enter and confirm your new password.")}
</p> </p>
<div class="form-field new_password1-new_password1"> <div class="form-field new_password1-new_password1">
<label for="new_password1">{% trans "New Password" %}</label> <label for="new_password1">${_("New Password")}</label>
<input id="new_password1" type="password" name="new_password1" aria-describedby="new_password_help_text" /> <input id="new_password1" type="password" name="new_password1" aria-describedby="new_password_help_text" />
</div> </div>
<div class="form-field new_password2-new_password2"> <div class="form-field new_password2-new_password2">
<label for="new_password2">{% trans "Confirm Password" %}</label> <label for="new_password2">${_("Confirm Password")}</label>
<input id="new_password2" type="password" name="new_password2" /> <input id="new_password2" type="password" name="new_password2" />
</div> </div>
<button type="submit" class="action action-primary action-update js-reset">{% trans "Reset My Password" %}</button> <input type="hidden" id="csrf_token" name="csrfmiddlewaretoken" value="${csrf_token}">
<button type="submit" class="action action-primary action-update js-reset">${_("Reset My Password")}</button>
</form> </form>
{% else %} % else:
<div class="status submission-error"> <div class="status submission-error">
<h4 class="message-title">{% trans "Invalid Password Reset Link" %}</h4> <h4 class="message-title">${_("Invalid Password Reset Link")}</h4>
<ul class="message-copy"> <ul class="message-copy">
{% blocktrans with start_link='<a href="/login">' end_link='</a>' %} ${Text(_((
This password reset link is invalid. It may have been used already. To reset your password, go to the {{ start_link }}sign-in{{ end_link }} page and select <strong>Forgot password</strong>. "This password reset link is invalid. It may have been used already. To reset your password, "
{% endblocktrans %} "go to the {start_link}sign-in{end_link} page and select {start_strong}Forgot password{end_strong}."
))).format(
start_link=HTML('<a href="/login">'),
end_link=HTML('</a>'),
start_strong=HTML('<strong>'),
end_strong=HTML('</strong>')
)
}
</ul> </ul>
</div> </div>
{% endif %} % endif
</div> </div>
</section> </section>
</div> </div>
{% endblock %} </%block>
{% extends "main_django.html" %} ## mako
{% load i18n %}
{% block title %} <%page expression_filter="h"/>
<%!
from django.utils.translation import ugettext as _
from django.utils.html import escape
%>
<%inherit file="../main.html"/>
<%block name="title">
<title> <title>
Manual Refund Manual Refund
</title> </title>
{% endblock %} </%block>
{% block headextra %} <%block name="headextra">
<style type="text/css"> <style type="text/css">
.errorlist,.messages { .errorlist,.messages {
...@@ -18,56 +27,57 @@ strong { ...@@ -18,56 +27,57 @@ strong {
padding-right: 10px; padding-right: 10px;
} }
</style> </style>
{% endblock %} </%block>
{% block body %} <%block name="body">
<div class="content-wrapper" id="content"> <div class="content-wrapper" id="content">
<div class="container about"> <div class="container about">
<h1>{% trans "Manual Refund" %}</h1> <h1>${_("Manual Refund")}</h1>
{% if messages %} % if messages:
<ul class="messages"> <ul class="messages">
{% for message in messages %} % for message in messages:
<li{% if message.tags %} class="{{ message.tags }}"{% endif %}>{{ message }}</li> <li class="${message.tags if message.tags else ''}">${message}</li>
{% endfor %} % endfor
</ul> </ul>
{% endif %} % endif
<form method="POST" id="refund_form"> <form method="POST" id="refund_form">
{% csrf_token %} <input type="hidden" id="csrf_token" name="csrfmiddlewaretoken" value="${csrf_token}" />
{{form.as_p}} ${form.as_p()}
<p> <p>
<input type="button" value="Cancel" onclick="javascript:location=location"/> <input type="submit" value="{% if cert %}Refund{% else %}Confirm{% endif %}" /> <input type="button" value="Cancel" onclick="javascript:location=location"/> <input type="submit" value="${'Refund' if cert else 'Confirm'}" />
</p> </p>
</form> </form>
{% if cert %} % if cert:
<section class="content-wrapper"> <section class="content-wrapper">
<h2> <h2>
{% trans "About to refund this order:" %} ${_("About to refund this order:")}
</h2> </h2>
<p> <p>
<strong>{% trans "Order Id:" %}</strong> {{cert.order.id}} <strong>${_("Order Id:")}</strong> ${cert.order.id}
</p> </p>
<p> <p>
<strong>{% trans "Enrollment:" %}</strong> {{enrollment.course_id|escape}} {{enrollment.mode}} ({% if enrollment.is_active %}{% trans "enrolled" %}{% else %}{% trans "unenrolled" %}{% endif %}) <strong>${_("Enrollment:")}</strong> ${escape(enrollment.course_id)} ${enrollment.mode}
(${_("enrolled") if enrollment.is_active else _("unenrolled")})
</p> </p>
<p> <p>
<strong>{% trans "Cost:" %}</strong> {{cert.unit_cost}} {{cert.currency}} <strong>${_("Cost:")}</strong> ${cert.unit_cost} ${cert.currency}
</p> </p>
<p> <p>
<strong>{% trans "CertificateItem Status:" %}</strong> {{cert.status}} <strong>${_("CertificateItem Status:")}</strong> ${cert.status}
</p> </p>
<p> <p>
<strong>{% trans "Order Status:" %}</strong> {{cert.order.status}} <strong>${_("Order Status:")}</strong> ${cert.order.status}
</p> </p>
<p> <p>
<strong>{% trans "Fulfilled Time:" %}</strong> {{cert.fulfilled_time}} <strong>${_("Fulfilled Time:")}</strong> ${cert.fulfilled_time}
</p> </p>
<p> <p>
<strong>{% trans "Refund Request Time:" %}</strong> {{cert.refund_requested_time}} <strong>${_("Refund Request Time:")}</strong> ${cert.refund_requested_time}
</p> </p>
</section> </section>
{% endif %} % endif
</div> </div>
</div> </div>
{% endblock %} </%block>
...@@ -6,7 +6,6 @@ ...@@ -6,7 +6,6 @@
{% block bodyclass %}view-in-course view-wiki{% endblock %} {% block bodyclass %}view-in-course view-wiki{% endblock %}
{% block headextra %} {% block headextra %}
<script type="text/javascript" src="/i18n.js"></script>
{% stylesheet 'course' %} {% stylesheet 'course' %}
{% stylesheet 'style-course-vendor' %} {% stylesheet 'style-course-vendor' %}
{% stylesheet 'style-course' %} {% stylesheet 'style-course' %}
......
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