Rename content to template content

WTForms sets the `id` of a `textarea` element to the variable name to which the
form control is assigned.

This conflicts with the page container, which is styled by targeting `#content`.
This commit is contained in:
Chris Hill-Scott
2016-01-22 12:15:47 +00:00
parent 48c0ae0140
commit 9ee8610da0
4 changed files with 7 additions and 5 deletions

View File

@@ -194,7 +194,7 @@ class TemplateForm(Form):
u'Template name',
validators=[DataRequired(message="Template name cannot be empty")])
template_type = SelectField(u'Template type', choices=[('sms', 'SMS')])
content = TextAreaField(
template_content = TextAreaField(
u'Message',
validators=[DataRequired(message="Template content cannot be empty")])

View File

@@ -40,7 +40,7 @@ def add_service_template(service_id):
if form.validate_on_submit():
tdao.insert_service_template(
form.name.data, form.template_type.data, form.content.data, service_id)
form.name.data, form.template_type.data, form.template_content.data, service_id)
return redirect(url_for(
'.manage_service_templates', service_id=service_id))
return render_template(
@@ -60,12 +60,14 @@ def edit_service_template(service_id, template_id):
abort(404)
else:
raise e
template['template_content'] = template['content']
form = TemplateForm(**template)
if form.validate_on_submit():
tdao.update_service_template(
template_id, form.name.data, form.template_type.data,
form.content.data, service_id)
form.template_content.data, service_id)
return redirect(url_for('.manage_service_templates', service_id=service_id))
return render_template(

View File

@@ -13,7 +13,7 @@ GOV.UK Notify | Edit template
<form method="post">
{{ textbox(form.name) }}
{{ textbox(form.template_type) }}
{{ textbox(form.content, highlight_tags=True) }}
{{ textbox(form.template_content, highlight_tags=True) }}
{{ page_footer(
'Save',
delete_link=url_for('.delete_service_template', service_id=service_id, template_id=template_id) if template_id or None,

View File

@@ -62,7 +62,7 @@ def test_should_redirect_when_saving_a_template(app_,
'id': template_id,
'name': name,
'template_type': type_,
"content": content,
"template_content": content,
"service": service_id
}
response = client.post(url_for(