示例#1
0
文件: __init__.py 项目: harsh376/Ajax
 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)
示例#2
0
 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)
示例#3
0
文件: __init__.py 项目: harsh376/Ajax
 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)
示例#4
0
 def delete(self, id):
     user = UserModel.query.filter_by(id=id).first()
     db.session.delete(user)
     db.session.commit()
     return build_object(user)
示例#5
0
 def patch(self, id):
     user = UserModel.query.filter_by(id=id).first()
     update_model(self.args, user)
     db.session.commit()
     return build_object(user)
示例#6
0
 def get(self, id):
     user = UserModel.query.filter_by(id=id).first()
     return build_object(user)
示例#7
0
文件: __init__.py 项目: harsh376/Ajax
 def delete(self, id):
     item = ItemModel.query.filter_by(id=id).first()
     db.session.delete(item)
     db.session.commit()
     return build_object(item)
示例#8
0
文件: __init__.py 项目: harsh376/Ajax
 def patch(self, id):
     item = ItemModel.query.filter_by(id=id).first()
     update_model(self.args, item)
     db.session.commit()
     return build_object(item)
示例#9
0
文件: __init__.py 项目: harsh376/Ajax
 def get(self, id):
     item = ItemModel.query.filter_by(id=id).first()
     return build_object(item)
示例#10
0
文件: __init__.py 项目: harsh376/Ajax
 def delete(self, id):
     user = UserModel.query.filter_by(id=id).first()
     db.session.delete(user)
     db.session.commit()
     return build_object(user)
示例#11
0
文件: __init__.py 项目: harsh376/Ajax
 def patch(self, id):
     user = UserModel.query.filter_by(id=id).first()
     update_model(self.args, user)
     db.session.commit()
     return build_object(user)
示例#12
0
文件: __init__.py 项目: harsh376/Ajax
 def get(self, id):
     user = UserModel.query.filter_by(id=id).first()
     return build_object(user)