def delete(self): ID = request.args.get("id") try: return crud_portaldata.delete_by_id(ID) except Exception as e: return error.CustomExceptionResponse(e)
def post(self): inpt = request.get_json() try: return crud.create(inpt) except Exception as e: return error.CustomExceptionResponse(e)
def delete(self): ID = request.args.get("id") try: return article_crud.delete_by_id(ID) except Exception as e: return error.CustomExceptionResponse(e)
def get(self): ID = request.args.get("id") try: return crud.read_by_id(ID) except Exception as e: return error.CustomExceptionResponse(e)
def put(self): ID = request.args.get("id") inpt = request.get_json() try: return crud.update_by_id(ID, inpt) except Exception as e: return error.CustomExceptionResponse(e)
def put(self): ID = request.args.get("id") inpt = request.get_json() inpt["date_modified"] = date.get_date_now() inpt["time_modified"] = date.get_time_now() try: return article_crud.update_by_id(ID, inpt) except Exception as e: return error.CustomExceptionResponse(e)
def post(self): inpt = request.get_json() inpt["date_created"] = date.get_date_now() inpt["time_created"] = date.get_time_now() inpt["date_modified"] = date.get_date_now() inpt["time_modified"] = date.get_time_now() try: return article_crud.create(inpt) except Exception as e: return error.CustomExceptionResponse(e)
def post(self): inpt = request.get_json() try: category_id = inpt["category_id"] category = crud_category.find_by_id(category_id, exception=True) inpt["category"] = category modeldata = PortalDataModel(**inpt) return CRUD.create_from_model(modeldata) except Exception as e: return error.CustomExceptionResponse(e)
def post(self): try: file = request.files["image"] folder_name = request.form.get("folder_name") if folder_name is None: raise Exception("component cannot be blank", 400) image = ImageModel(file) url = image.upload_publicly(folder_name=folder_name) return {"message": message.OK, "url": url}, 200 except Exception as e: error.CustomExceptionResponse(e)
def put(self): ID = request.args.get("id") inpt = request.get_json() try: datamodel = crud_portaldata.find_by_id(ID, exception=True) category_id = inpt["category_id"] category = crud_category.find_by_id(category_id, exception=True) inpt["category"] = category return crud_portaldata.update_from_model(datamodel, inpt) except Exception as e: return error.CustomExceptionResponse(e)
def get(self): # OPTION 1 find by id ID = request.args.get("id") # OPTION 2 find by category id category_id = request.args.get("category_id") try: if ID: return crud_portaldata.read_by_id(ID) return crud_portaldata.read({"category_id": category_id}, many=True, reverse_id=True) except Exception as e: return error.CustomExceptionResponse(e)
def get(self): try: return crud_portaldata.read_all(reverse_id=True) except Exception as e: return error.CustomExceptionResponse(e)
def get(self): try: return crud.read_all() except Exception as e: return error.CustomExceptionResponse(e)
def get(self): try: return article_crud.read_all(reverse_id=True) except Exception as e: return error.CustomExceptionResponse(e)