mirror of
https://github.com/GSA/notifications-api.git
synced 2026-02-01 07:35:34 -05:00
Replace how .dump is called
As with `.load`, only data is now returned instead of a tuple.
This commit is contained in:
@@ -111,7 +111,7 @@ def create_template(service_id):
|
||||
|
||||
dao_create_template(new_template)
|
||||
|
||||
return jsonify(data=template_schema.dump(new_template).data), 201
|
||||
return jsonify(data=template_schema.dump(new_template)), 201
|
||||
|
||||
|
||||
@template_blueprint.route('/<uuid:template_id>', methods=['POST'])
|
||||
@@ -140,10 +140,10 @@ def update_template(service_id, template_id):
|
||||
if "reply_to" in data:
|
||||
check_reply_to(service_id, data.get("reply_to"), fetched_template.template_type)
|
||||
updated = dao_update_template_reply_to(template_id=template_id, reply_to=data.get("reply_to"))
|
||||
return jsonify(data=template_schema.dump(updated).data), 200
|
||||
return jsonify(data=template_schema.dump(updated)), 200
|
||||
|
||||
current_data = dict(template_schema.dump(fetched_template).data.items())
|
||||
updated_template = dict(template_schema.dump(fetched_template).data.items())
|
||||
current_data = dict(template_schema.dump(fetched_template).items())
|
||||
updated_template = dict(template_schema.dump(fetched_template).items())
|
||||
updated_template.update(data)
|
||||
|
||||
# Check if there is a change to make.
|
||||
@@ -160,13 +160,13 @@ def update_template(service_id, template_id):
|
||||
if update_dict.archived:
|
||||
update_dict.folder = None
|
||||
dao_update_template(update_dict)
|
||||
return jsonify(data=template_schema.dump(update_dict).data), 200
|
||||
return jsonify(data=template_schema.dump(update_dict)), 200
|
||||
|
||||
|
||||
@template_blueprint.route('/precompiled', methods=['GET'])
|
||||
def get_precompiled_template_for_service(service_id):
|
||||
template = get_precompiled_letter_template(service_id)
|
||||
template_dict = template_schema.dump(template).data
|
||||
template_dict = template_schema.dump(template)
|
||||
|
||||
return jsonify(template_dict), 200
|
||||
|
||||
@@ -175,23 +175,23 @@ def get_precompiled_template_for_service(service_id):
|
||||
def get_all_templates_for_service(service_id):
|
||||
templates = dao_get_all_templates_for_service(service_id=service_id)
|
||||
if str(request.args.get('detailed', True)) == 'True':
|
||||
data = template_schema.dump(templates, many=True).data
|
||||
data = template_schema.dump(templates, many=True)
|
||||
else:
|
||||
data = template_schema_no_detail.dump(templates, many=True).data
|
||||
data = template_schema_no_detail.dump(templates, many=True)
|
||||
return jsonify(data=data)
|
||||
|
||||
|
||||
@template_blueprint.route('/<uuid:template_id>', methods=['GET'])
|
||||
def get_template_by_id_and_service_id(service_id, template_id):
|
||||
fetched_template = dao_get_template_by_id_and_service_id(template_id=template_id, service_id=service_id)
|
||||
data = template_schema.dump(fetched_template).data
|
||||
data = template_schema.dump(fetched_template)
|
||||
return jsonify(data=data)
|
||||
|
||||
|
||||
@template_blueprint.route('/<uuid:template_id>/preview', methods=['GET'])
|
||||
def preview_template_by_id_and_service_id(service_id, template_id):
|
||||
fetched_template = dao_get_template_by_id_and_service_id(template_id=template_id, service_id=service_id)
|
||||
data = template_schema.dump(fetched_template).data
|
||||
data = template_schema.dump(fetched_template)
|
||||
template_object = fetched_template._as_utils_template_with_personalisation(
|
||||
request.args.to_dict()
|
||||
)
|
||||
@@ -217,7 +217,7 @@ def get_template_version(service_id, template_id, version):
|
||||
service_id=service_id,
|
||||
version=version
|
||||
)
|
||||
).data
|
||||
)
|
||||
return jsonify(data=data)
|
||||
|
||||
|
||||
@@ -226,7 +226,7 @@ def get_template_versions(service_id, template_id):
|
||||
data = template_history_schema.dump(
|
||||
dao_get_template_versions(service_id=service_id, template_id=template_id),
|
||||
many=True
|
||||
).data
|
||||
)
|
||||
return jsonify(data=data)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user