Remove wrapper around response object

Before:
```json
{'data': {'template': '…'}}
```

There’s no need to wrap the response in key because there will only
ever be one valid key for the template preview endpoint.

Flatter is better:
```json
{
  'content': '…',
  'subject': '…',
  'template_type': '…',
  …
}
```

The response will be different if there’s an error, but you should be
checking the status code first anyway.

This commit:
- changes the template preview endpoint to return the above format
- adds a test to make sure that the original `/service/…/template/…`
  endpoint still returns JSON in the same format (with a `data` key)
This commit is contained in:
Chris Hill-Scott
2016-06-17 12:57:43 +01:00
parent cf91ce57fc
commit 0d9519c656
2 changed files with 42 additions and 9 deletions

View File

@@ -108,7 +108,7 @@ def preview_template_by_id_and_service_id(service_id, template_id):
data['subject'], data['content'] = template_object.replaced_subject, template_object.replaced
return jsonify(data=data)
return jsonify(data)
@template.route('/<uuid:template_id>/version/<int:version>')