Пример #1
0
    def post(self):
        json_data = request.get_json()
        current_user = get_jwt_identity()
        try:
            data = history_schema.load(data=json_data)
        except ValidationError as errors:
            return {'message': 'Validation errors', 'errors': errors.messages}, HTTPStatus.BAD_REQUEST

        history = History(**data)
        history.user_id = current_user
        history.save()

        return history_schema.dump(history), HTTPStatus.CREATED