Files
notifications-api/app/events/rest.py
Adam Shimali b33312b855 Change endpoint responses where there are marshalling, unmarshalling
or param errors to raise invalid data exception. That will cause
those responses to be handled in by errors.py, which will log
the errors.

Set most of schemas to strict mode so that marshmallow will raise
exception rather than checking for errors in return tuple from load.

Added handler to errors.py for marshmallow validation errors.
2016-06-15 14:37:51 +01:00

22 lines
491 B
Python

from flask import (
Blueprint,
jsonify,
request
)
from app.errors import register_errors
from app.schemas import event_schema
from app.dao.events_dao import dao_create_event
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).data
dao_create_event(event)
return jsonify(data=event_schema.dump(event).data), 201