def get(self): data = request.get_json() name = data["name"] store = StoreModel.find_by_name(name) if store: return store_schema.dump(store) return {"msg": "Store not found"}, 404
def put(self, name): if StoreModel.find_by_name(name): return {"message": f"An store with name {name} already exists!"}, 400 store = StoreModel(name) try: store.save_to_db() except: return {"message": "An error occured while creating store!"}, 500 return store.json(), 201
def post(self, name): if StoreModel.find_by_name(name): return {"message":f"A store with the name {name} already exists"}, 400 store = StoreModel(name) try: store.save_to_db() except Exception as e: return {"message":"An error occurred while creating the store."}, 500 return store.json(), 500
def post(self, name): if StoreModel.find_by_name(name): return {"message": "store already exists"} store = StoreModel(name) try: store.save_to_db() except: return {"message": "An error occurred while creating store"}, 500 return store.json(), 201
def delete(self): data = request.get_json() name = data["name"] store = StoreModel.find_by_name(name) if store: store.delete_from_db() else: return {"msg": "Store does not exist"}, 400 return {"msg": "Store deleted"}
def post(self, name): if StoreModel.find_by_name(name): return {"Message":"Store is exists"}, 400 store = StoreModel(name) try: store.save_to_db() except: return {"Message":"Store save db error"}, 500 return store.json(), 201
def post(self, name): store = StoreModel.find_by_name(name) if store: return { 'message': "a store with the name {}, already exist".format(name) }, 400 store = StoreModel(name) try: store.add_to_db() except: return {'message': 'an error occured while adding store'}, 500 return store.json(), 201
def post(self, name): if StoreModel.find_by_name(name): return { 'message': 'A store with the name {} already exists'.format(name) }, 400 store = StoreModel(name) try: store.save_to_db() except: return {'message': 'An error ocurred while creating the store ):'} return store.json()
def post(self): data = request.get_json() name = data["name"] store = StoreModel.find_by_name(name) if store: return {"msg": "Store exists already"}, 400 store = StoreModel(name=name) try: store.save_to_db() except: return {"msg": "Error occured"}, 500 return {"msg": "Added the store"}, 201
def post(self, name): if StoreModel.find_by_name(name): return { 'message': "A store with name '{}' already exists".format(name) }, 404 store = StoreModel(name) try: store.save_to_db() except: return { 'message': 'An error occurred while creating the store.' }, 500 return store.json(), 201
def delete(self): user = UserModel.find_by_id(get_jwt_identity()) if not user.seller: return {"msg": "User is not a seller"}, 403 data = request.get_json() name = data["name"] store = StoreModel.find_by_name(name) if store: store.delete_from_db() else: return {"msg": "Store does not exist"}, 400 return {"msg": "Store deleted"}
def post(self): user = UserModel.find_by_id(get_jwt_identity()) if not user.seller: return {"msg": "User is not a seller"}, 403 data = request.get_json() name = data["name"] store = StoreModel.find_by_name(name) if store: return {"msg": "Store exists already"}, 400 store = StoreModel(name=name) try: store.save_to_db() except: return {"msg": "Error occured"}, 500 return {"msg": "Added the store"}, 201
def get(self, name): store = StoreModel.find_by_name(name) if store: return store.json() return {'message': 'Store not found'}, 404
def delete(self, name): store = StoreModel.find_by_name(name) if store: store.delete_from_db() return {'message': 'Store deleted'}
def get(self, name): store = StoreModel.find_by_name(name) if store: return store.json() else: return {"message": "Store not found!"}, 404
def delete(self, name): store = StoreModel.find_by_name(name) if store: store.delete_from_db() return {"message": "Store was deleted!"}, 404
def delete(self, name): store = StoreModel.find_by_name(name) if store: store.delete_from_db() return {"Message": "Delete Successful!"}
def get(self, name): store = StoreModel.find_by_name(name) return store.json() if store else ({'message': 'store not found'}, 400)
def get(self, name): store = StoreModel.find_by_name(name) if store: return store.json() return {"Message":"store does not exists"}, 400