def post(self): try: assert self.args['name'] except AssertionError: abort(404) try: new_item = ItemModel(name=self.args['name'], order=self.args['order']) db.session.add(new_item) db.session.commit() except: raise IntegrityError return build_object(new_item)
def post(self): try: assert self.args['first_name'] assert self.args['email'] assert self.args['external_auth_type'] assert self.args['external_auth_id'] except AssertionError: abort(400) try: new_user = UserModel( first_name=self.args['first_name'], last_name=self.args['last_name'], email=self.args['email'], photo_url=self.args['photo_url'], external_auth_type=self.args['external_auth_type'], external_auth_id=self.args['external_auth_id'], ) db.session.add(new_user) db.session.commit() return build_object(new_user) except IntegrityError: abort(409)
def delete(self, id): user = UserModel.query.filter_by(id=id).first() db.session.delete(user) db.session.commit() return build_object(user)
def patch(self, id): user = UserModel.query.filter_by(id=id).first() update_model(self.args, user) db.session.commit() return build_object(user)
def get(self, id): user = UserModel.query.filter_by(id=id).first() return build_object(user)
def delete(self, id): item = ItemModel.query.filter_by(id=id).first() db.session.delete(item) db.session.commit() return build_object(item)
def patch(self, id): item = ItemModel.query.filter_by(id=id).first() update_model(self.args, item) db.session.commit() return build_object(item)
def get(self, id): item = ItemModel.query.filter_by(id=id).first() return build_object(item)