mirror of
https://github.com/GSA/notifications-api.git
synced 2026-01-31 23:26:23 -05:00
Replace how .load is called
https://marshmallow.readthedocs.io/en/stable/upgrading.html#schemas-are-always-strict `.load` doesn't return a `(data, errors)` tuple any more - only data is returned. A `ValidationError` is raised if validation fails. The code now relies on the `marshmallow_validation_error` error handler to handle errors instead of having to raise an `InvalidRequest`. This has no effect on the response that is returned (a test has been modified to check). Also added a new `password` field to the `UserSchema` so that we don't have to specially check for password errors in the `.create_user` endpoint - we can let marshmallow handle them.
This commit is contained in:
@@ -48,7 +48,8 @@ def get_notification_by_id(notification_id):
|
||||
|
||||
@notifications.route('/notifications', methods=['GET'])
|
||||
def get_all_notifications():
|
||||
data = notifications_filter_schema.load(request.args).data
|
||||
data = notifications_filter_schema.load(request.args)
|
||||
|
||||
include_jobs = data.get('include_jobs', False)
|
||||
page = data.get('page', 1)
|
||||
page_size = data.get('page_size', current_app.config.get('API_PAGE_SIZE'))
|
||||
@@ -83,13 +84,10 @@ def send_notification(notification_type):
|
||||
msg = msg + ", please use the latest version of the client" if notification_type == LETTER_TYPE else msg
|
||||
raise InvalidRequest(msg, 400)
|
||||
|
||||
notification_form, errors = (
|
||||
notification_form = (
|
||||
sms_template_notification_schema if notification_type == SMS_TYPE else email_notification_schema
|
||||
).load(request.get_json())
|
||||
|
||||
if errors:
|
||||
raise InvalidRequest(errors, status_code=400)
|
||||
|
||||
check_rate_limiting(authenticated_service, api_user)
|
||||
|
||||
template, template_with_content = validate_template(
|
||||
|
||||
Reference in New Issue
Block a user