mirror of
https://github.com/GSA/notifications-api.git
synced 2026-02-03 01:41:05 -05:00
Changed db queries to use one, which throws NoResultFound exception, this exception is dealt with in our error handlers.
Now a lot of the if none checks can be removed.
This commit is contained in:
@@ -32,13 +32,10 @@ from app.errors import register_errors
|
||||
register_errors(notifications)
|
||||
|
||||
|
||||
@notifications.route('/notifications/<string:notification_id>', methods=['GET'])
|
||||
@notifications.route('/notifications/<uuid:notification_id>', methods=['GET'])
|
||||
def get_notifications(notification_id):
|
||||
try:
|
||||
notification = notifications_dao.get_notification(api_user['client'], notification_id)
|
||||
return jsonify({'notification': notification_status_schema.dump(notification).data}), 200
|
||||
except NoResultFound:
|
||||
return jsonify(result="error", message="not found"), 404
|
||||
notification = notifications_dao.get_notification(api_user['client'], notification_id)
|
||||
return jsonify({'notification': notification_status_schema.dump(notification).data}), 200
|
||||
|
||||
|
||||
@notifications.route('/notifications', methods=['GET'])
|
||||
@@ -152,13 +149,6 @@ def send_notification(notification_type):
|
||||
template_id=notification['template'],
|
||||
service_id=service_id
|
||||
)
|
||||
if not template:
|
||||
return jsonify(
|
||||
result="error",
|
||||
message={
|
||||
'template': ['Template {} not found for service {}'.format(notification['template'], service_id)]
|
||||
}
|
||||
), 404
|
||||
|
||||
template_object = Template(template.__dict__, notification.get('personalisation', {}))
|
||||
if template_object.missing_data:
|
||||
|
||||
Reference in New Issue
Block a user