31 lines
961 B
Python
31 lines
961 B
Python
from flask import Blueprint, request
|
|
from ..schemas import model
|
|
from .. import impl
|
|
from ..services.auth_guard import auth_guard
|
|
import json
|
|
import logging
|
|
from marshmallow import ValidationError
|
|
from . import verify_if_request_is_json
|
|
from BreCal.validators.validation_error import create_dynamic_exception_response, create_validation_error_response
|
|
|
|
bp = Blueprint('user', __name__)
|
|
|
|
@bp.route('/user', methods=['put'])
|
|
@auth_guard() # no restriction by role
|
|
def PutUser():
|
|
|
|
try:
|
|
verify_if_request_is_json(request)
|
|
|
|
content = request.get_json(force=True)
|
|
loadedModel = model.UserSchema().load(data=content, many=False, partial=True)
|
|
return impl.user.PutUser(loadedModel)
|
|
|
|
except ValidationError as ex:
|
|
return create_validation_error_response(ex=ex, status_code=400)
|
|
|
|
except Exception as ex:
|
|
return create_dynamic_exception_response(ex=None, status_code=400, message="bad format")
|
|
|
|
|