Esempio n. 1
0
    def post(self):
        args = get_args()
        if not args:
            return response("Invalid parameters", 422)

        try:
            admin = Admin(args["name"], args["email"], args["password"])
            admin.add(admin)
            query = Admin.query.get(admin.id)
        except SQLAlchemyError as e:
            return rollback(e, db)
        else:
            return schema.dump(query).data, 201
Esempio n. 2
0
    def post(self):
        args = get_args()
        if not args:
            return send_message("Parâmetros inválidos!", 422)

        try:
            admin = Admin(args["nome"], args["email"], args["password"])
            admin.add(admin)
            query = Admin.query.get(admin.id)
        except SQLAlchemyError as e:
            return rollback(e, db)
        else:
            return schema.dump(query).data, 201