Exemplo n.º 1
0
 def update(self, id):
     schema = UserSchema()
     # Load update data, then find and update user
     update_data = schema.load_data(request.form)
     user = User.query.get(id)
     user.update_fields(update_data)
     db.session.commit()
     # Return success
     return jsonify(schema.dump_data(user))
Exemplo n.º 2
0
 def create(self):
     schema = UserSchema()
     # Load user data
     user = schema.load_data(request.form)
     # Add to database
     db.session.add(user)
     db.session.commit()
     # Return success
     return jsonify(schema.dump_data(user))
Exemplo n.º 3
0
 def retrieve(self, id):
     schema = UserSchema()
     # Find user
     user = User.query.get(id)
     # Return failed
     return jsonify(schema.dump_data(user))