mirror of
https://github.com/GSA/notifications-api.git
synced 2025-12-20 15:31:15 -05:00
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.
17 lines
469 B
Python
17 lines
469 B
Python
from flask import Blueprint, jsonify, request
|
|
|
|
from app.dao.events_dao import dao_create_event
|
|
from app.errors import register_errors
|
|
from app.schemas import event_schema
|
|
|
|
events = Blueprint('events', __name__, url_prefix='/events')
|
|
register_errors(events)
|
|
|
|
|
|
@events.route('', methods=['POST'])
|
|
def create_event():
|
|
data = request.get_json()
|
|
event = event_schema.load(data)
|
|
dao_create_event(event)
|
|
return jsonify(data=event_schema.dump(event).data), 201
|