Fix count of columns on breaking change page

For some reason we were rebuilding `new_template` as a dictionary,
without the `placeholders` attribute. This meant that we were never
actually counting the placeholders, just counting the length of `None`
and adding 1 to it.

So this commit fixes that, beefs up the tests, and makes sure that
everything is pluralised properly.
This commit is contained in:
Chris Hill-Scott
2017-03-06 13:08:27 +00:00
parent 536d091d85
commit 5081d83c19
3 changed files with 13 additions and 9 deletions

View File

@@ -262,12 +262,7 @@ def edit_service_template(service_id, template_id):
return render_template(
'views/templates/breaking-change.html',
template_change=template_change,
new_template={
'name': form.name.data,
'subject': subject,
'content': form.template_content.data,
'id': new_template.id
},
new_template=new_template,
column_headings=list(ascii_uppercase[:len(new_template.placeholders) + 1]),
example_rows=[
first_column_headings[new_template.template_type] + list(new_template.placeholders),

View File

@@ -41,7 +41,8 @@
<p>
When you send messages using this template youll need
{{ new_template.placeholders|length + 1 }} columns of data:
{{ new_template.placeholders|length + 1 }}
column{{ 's' if new_template.placeholders|length > 0 else '' }} of data:
</p>
<div class="spreadsheet">