Exemplo n.º 1
0
 def delete(self, id):
     try:
         obj = db.session.query(Colours).filter_by(id=id).one()
         if obj:
             db.session.delete(obj)
             db.session.commit()
             logger.info("Colour data deleted succesfully based on Id")
             return ("succesfully deleted the colour")
         logger.warning("Colour does not exists with this id")
         return ("no colour is found with this id")
     except:
         raise PostFailed("call failed")
Exemplo n.º 2
0
 def get(self):
     try:
         product = db.session.query(Products).order_by(Products.id).all()
         if product:
             schema = ProductsSchema(many=True)
             data = schema.dump(product).data
             logger.info("Product data fetched succesfully ")
             return data
         logger.warning("no data is available in products")
         return ("no data is available in products")
     except:
         raise PostFailed("call failed")
Exemplo n.º 3
0
 def delete(self,id):
     try:
         obj = db.session.query(Product_Class).filter_by(id=id).one()
         if obj:
             db.session.delete(obj)
             db.session.commit()
             logger.info("Product-Class deleted succesfully")
             return("succesfully deleted the product-class")
         logger.warning("Product-Class does not exists with this id")
         return ("no product-class is found with this id")
     except:
         raise PostFailed("call failed")
Exemplo n.º 4
0
 def delete(self,id):
     try:
         obj = db.session.query(Sub_Categories).filter_by(id=id).one()
         if obj:
             db.session.delete(obj)
             db.session.commit()
             logger.info("Sub-Category deleted succesfully")
             return("succesfully deleted the categorie")
         logger.warning("Sub-Category does not exists with this id")
         return ("no category is found with this id")
     except:
         raise PostFailed("call failed")
Exemplo n.º 5
0
 def get(self,id):
     try:
         categorie = db.session.query(Sub_Categories).filter(Sub_Categories.id == id).first()
         if categorie:
             schema = GetSub_CategoriesSchema()
             data = schema.dump(categorie).data
             logger.info("Sub-Category data fetched succesfully based on Id")
             return data
         logger.warning("Sub-Category does not exists with this id")
         return ("no data is available with this id")
     except:
         raise PostFailed("call failed")
Exemplo n.º 6
0
 def get(self,id):
     try:
         product_class = db.session.query(Product_Class).filter(Product_Class.id == id).first()
         if product_class:
             schema = Product_ClassGetSchema()
             data = schema.dump(product_class).data
             logger.info("Product-Class data fetched succesfully based on Id")
             return data
         logger.warning("Product-Class does not exists with this id")
         return ("no data is available with this id")
     except:
         raise PostFailed("call failed")
Exemplo n.º 7
0
 def get(self,id):
     try:
         categorie = db.session.query(Categories).filter(Categories.id == id).first()
         if categorie:
             schema = CategoryGetSchema()
             data = schema.dump(categorie).data
             logger.info("Category data fetched succesfully based on Id")
             return data
         else:
             logger.warning("Category does not exists")
             return ("Category does not exists")
     except:
         raise PostFailed("call failed")
Exemplo n.º 8
0
 def delete(self, id):
     try:
         obj = db.session.query(Sizes).filter(Sizes.id == id).first()
         if obj:
             db.session.delete(obj)
             db.session.commit()
             logger.info("Size data deleted succesfully")
             return ("success")
         else:
             logger.warning("Size does not exists with this id")
             return ("Size does not exists with this id")
     except:
         raise PostFailed("call failed")
Exemplo n.º 9
0
 def delete(self, id):
     try:
         obj = db.session.query(Roles).filter(Roles.id == id).first()
         if obj:
             db.session.delete(obj)
             db.session.commit()
             logger.info("Role deleted successfully")
             return ("Role deleted successfully")
         else:
             logger.info("No data is found on this id")
             return ("No data is found on this id")
     except:
         raise PostFailed("call failed")
 def get(self):
     try:
         categorie = db.session.query(Sub_Categories).order_by(
             Sub_Categories.id).all()
         if categorie:
             schema = GetSub_CategoriesSchema(many=True)
             data = schema.dump(categorie).data
             logger.info("Sub-Category data fetched succesfully ")
             return data
         logger.warning("no data is available in sub-categories")
         return ("No data is available in sub-categories")
     except:
         raise PostFailed("call failed due to some reasons")
 def get(self, id):
     try:
         permission = db.session.query(Permissions).filter(
             Permissions.id == id).first()
         if permission:
             schema = PermissionsGetSchema()
             data = schema.dump(permission).data
             logger.info("permission data fetched succesfully based on Id")
             return data
         logger.warning("permission does not exists with this id")
         return ("no data is available with this id")
     except:
         raise PostFailed("call failed")
Exemplo n.º 12
0
 def put(self,id):
     try:
         categorie = db.session.query(Sub_Categories).filter(Sub_Categories.id == id).update(request.get_json())
         if categorie:
             db.session.commit()
             obj=db.session.query(Sub_Categories).filter(Sub_Categories.id==id).one()
             schema = Sub_CategoriesSchema()
             data = schema.dump(obj).data
             logger.info("Sub-Category updated succesfully")
             return data
         logger.warning("Sub-Category does not exists with this id")
         return("Sub-Categorie with this id is not available")
     except:
         raise PostFailed("call failed")
Exemplo n.º 13
0
 def put(self, id):
     try:
         obj = db.session.query(Sizes).filter(Sizes.id == id).update(
             request.get_json())
         if obj:
             db.session.commit()
             obj = db.session.query(Sizes).filter_by(id=id).one()
             schema = SizesSchema()
             data = schema.dump(obj).data
             logger.info("Size data updated succesfully")
             return data
         else:
             logger.warning("Size does not exists with this id")
             return ("Size does not exists with this id")
     except:
         raise PostFailed("call failed")
Exemplo n.º 14
0
 def put(self, id):
     try:
         obj = db.session.query(Roles).filter(Roles.id == id).update(
             request.get_json())
         if obj:
             db.session.commit()
             abc = db.session.query(Roles).filter_by(id=id).one()
             schema = RolesSchema()
             data = schema.dump(abc).data
             logger.info("Data has updated successfully")
             return data
         else:
             logger.warning("No data is found on this id")
             return ("No data is found on this id")
     except:
         raise PostFailed("call failed")
Exemplo n.º 15
0
 def put(self,id):
     try:
         file = request.files['image']
         upload_folder = os.path.basename('/upload')
         f = os.path.join(upload_folder, file.filename)
         file.save(f)
         dit ={"image": f}
         categorie = db.session.query(Sub_Categories).filter_by(id = id).update(dit)
         if categorie:
             db.session.commit()
             obj=db.session.query(Sub_Categories).filter_by(id=id).one()
             schema = Sub_CategoriesSchema()
             data = schema.dump(obj).data
             logger.info("Sub-Category image updated succesfully")
             return data
         logger.warning("Sub-Category does not exists with this id")
         return("categorie with this id is not available")
     except:
         raise PostFailed("call failed")
Exemplo n.º 16
0
 def post(self):
     try:
         da = request.get_json()
         name = da['name']
         dit = {key: value for key, value in da.items()}
         existing_one = db.session.query(Products).filter(
             Products.name == name).one_or_none()
         if existing_one is None:
             schema = ProductsSchema()
             new_product = schema.load(dit,
                                       session=db.session,
                                       partial=True).data
             db.session.add(new_product)
             db.session.commit()
             data = schema.dump(new_product).data
             logger.info("Product data added succesfully ")
             return data
         logger.warning("product name already exists")
         return ("product name already exists")
     except:
         raise PostFailed("call failed")