Commit b6b442d8 by Peter Fogg

[safe templates] Financial assistance form.

parent 849e3b79
...@@ -5,18 +5,19 @@ ...@@ -5,18 +5,19 @@
'jquery', 'jquery',
'underscore', 'underscore',
'gettext', 'gettext',
'edx-ui-toolkit/js/utils/html-utils',
'js/financial-assistance/models/financial_assistance_model', 'js/financial-assistance/models/financial_assistance_model',
'js/student_account/views/FormView', 'js/student_account/views/FormView',
'text!../../../templates/financial-assistance/financial_assessment_form.underscore', 'text!../../../templates/financial-assistance/financial_assessment_form.underscore',
'text!../../../templates/financial-assistance/financial_assessment_submitted.underscore', 'text!../../../templates/financial-assistance/financial_assessment_submitted.underscore',
'text!templates/student_account/form_field.underscore', 'text!templates/student_account/form_field.underscore'
'string_utils'
], ],
function( function(
Backbone, Backbone,
$, $,
_, _,
gettext, gettext,
HtmlUtils,
FinancialAssistanceModel, FinancialAssistanceModel,
FormView, FormView,
formViewTpl, formViewTpl,
...@@ -73,10 +74,11 @@ ...@@ -73,10 +74,11 @@
render: function(html) { render: function(html) {
var data = _.extend( this.model.toJSON(), this.context, { var data = _.extend( this.model.toJSON(), this.context, {
fields: html || '', fieldsHtml: html || '',
HtmlUtils: HtmlUtils
}); });
this.$el.html(_.template(this.tpl)(data)); HtmlUtils.setHtml(this.$el, HtmlUtils.template(this.tpl)(data));
this.postRender(); this.postRender();
this.validateCountry(); this.validateCountry();
...@@ -85,7 +87,7 @@ ...@@ -85,7 +87,7 @@
}, },
renderSuccess: function() { renderSuccess: function() {
this.$el.html(_.template(successTpl)({ HtmlUtils.setHtml(this.$el, HtmlUtils.template(successTpl)({
course: this.model.get('course'), course: this.model.get('course'),
dashboard_url: this.context.dashboard_url dashboard_url: this.context.dashboard_url
})); }));
...@@ -94,18 +96,15 @@ ...@@ -94,18 +96,15 @@
}, },
saveError: function(error) { saveError: function(error) {
/*jslint maxlen: 500 */ var msg = gettext(
var txt = [ 'An error has occurred. Wait a few minutes and then try to submit the application again. If you continue to have issues please contact support.' // jshint ignore:line
'An error has occurred. Wait a few minutes and then try to submit the application again.', );
'If you continue to have issues please contact support.'
],
msg = gettext(txt.join(' '));
if (error.status === 0) { if (error.status === 0) {
msg = gettext('An error has occurred. Check your Internet connection and try again.'); msg = gettext('An error has occurred. Check your Internet connection and try again.');
} }
this.errors = ['<li>' + msg + '</li>']; this.errors = [HtmlUtils.joinHtml('<li>', msg, '</li>')];
this.setErrors(); this.setErrors();
this.element.hide( this.$resetSuccess ); this.element.hide( this.$resetSuccess );
this.toggleDisableButton(false); this.toggleDisableButton(false);
...@@ -119,22 +118,24 @@ ...@@ -119,22 +118,24 @@
var $submissionContainer = $('.submission-error'), var $submissionContainer = $('.submission-error'),
$errorMessageContainer = $submissionContainer.find('.message-copy'), $errorMessageContainer = $submissionContainer.find('.message-copy'),
$countryLabel = $('#user-country-title'), $countryLabel = $('#user-country-title'),
txt = [ msg = HtmlUtils.interpolateHtml(
'Please go to your {link_start}profile page{link_end} ', // Translators: link_start and link_end
'and provide your country of residence.' // denote the html to link back to the
], // profile page.
msg = window.interpolate_text( gettext('Please go to your {link_start}profile page{link_end} and provide your country of residence.'), // jshint ignore:line
// Translators: link_start and link_end denote the html to link back to the profile page.
gettext(txt.join('')),
{ {
link_start: '<a href="' + this.context.account_settings_url + '">', link_start: HtmlUtils.joinHtml('<a href="', this.context.account_settings_url, '">'),
link_end: '</a>' link_end: HtmlUtils.HTML('</a>')
} }
); );
if( !this.model.get('country') ){ if( !this.model.get('country') ){
$countryLabel.addClass('error'); $countryLabel.addClass('error');
$errorMessageContainer.append("<li>" + msg + "</li>"); HtmlUtils.append($errorMessageContainer, HtmlUtils.joinHtml(
HtmlUtils.HTML("<li>"),
msg,
HtmlUtils.HTML("</li>")
));
this.toggleDisableButton(true); this.toggleDisableButton(true);
$submissionContainer.removeClass('hidden'); $submissionContainer.removeClass('hidden');
} }
......
<%page expression_filter="h"/>
<%inherit file="../main.html"/> <%inherit file="../main.html"/>
<%! <%!
import json import json
......
<%page expression_filter="h"/>
<%inherit file="../main.html"/> <%inherit file="../main.html"/>
<% <%
from django.core.urlresolvers import reverse from django.core.urlresolvers import reverse
......
...@@ -36,10 +36,10 @@ ...@@ -36,10 +36,10 @@
</div> </div>
</div> </div>
<%= fields %> <%= HtmlUtils.HTML(fieldsHtml) %>
<div class="cta-wrapper clearfix"> <div class="cta-wrapper clearfix">
<a href="<%- student_faq_url %>" class="nav-link"><%- interpolate_text( <a href="<%- student_faq_url %>" class="nav-link"><%- StringUtils.interpolate(
gettext('Back to {platform} FAQs'), gettext('Back to {platform} FAQs'),
{platform: platform_name} {platform: platform_name}
) %></a> ) %></a>
......
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