def get(cls, name: str): shop_list = ShoppingListModel.find_by_name(name) if shop_list: return shopping_list_schema.dump(shop_list), 200 return {"message": gettext("shop_list_not_found")}, 404
def delete(cls, user_id: int): user = UserModel.find_by_id(user_id) if not user: return {"message": gettext("user_not_found")}, 404 user.delete_from_db() return {"message": gettext("user_deleted")}, 200
def get(cls, user_id: int): user = UserModel.find_by_id(user_id) if not user: return {"message": gettext("user_not_found")}, 404 return user_schema.dump(user), 200
def get(cls, name: str): item = ItemModel.find_by_name(name) if item: return item_schema.dump(item), 200 return {'message': gettext('item_not_found')}, 404
def delete(cls, name: str): store = StoreModel.find_by_name(name) if store: store.delete_from_db() return {"message": gettext("store_deleted")}
def post(cls): jti = get_raw_jwt()["jti"] # jti is "JWT ID", a unique identifier for a JWT. user_id = get_jwt_identity() BLACKLIST.add(jti) return {"message": gettext("user_logged_out").format(user_id)}, 200
def get(cls, name: str): item = ItemModel.find_by_name(name) if item: return item_schema.dump(item) return {"message": gettext("item_not_found")}, 404
def get(cls, user_id: int, offer_id: int): offer = OfferModel.find_by_id(offer_id) if not offer: return {"message": gettext("offer_not_found")}, 404 return offer_schema.dump(offer), 200
def get(cls, email: str): customer = CustomerModel.find_by_email(email) if customer: return customer_schema.dump(customer), 200 return {"message": gettext("CUSTOMER_NOT_FOUND")}, 404
def delete(cls, name: str): store = StoreModel.find_by_name(name) if store: store.delete_from_db() return {'message': gettext('store_deleted')}
def postlogoutpage(user_id): return render_template("post_logout.html", text=gettext("user_logged_out").format(user_id))
def postloginpage(response): if response == "success": return render_template("post_login.html", text=gettext("user_logged_in")) return render_template("post_login.html", text=gettext("user_invalid_credentials"))
def get(cls, id: int): payment = PaymentModel.find_by_id(id) if order: return payment_schema.dump(payment), 200 return {"message": gettext("order_not_found")}, 404
def delete(cls, name: str): item = ItemModel.find_by_name(name) if item: item.delete_from_db() return {'message': gettext("generic_deleted").format(name)} return {'message': gettext("item_not_found").format(name)}, 404
def get(cls, name: str): post = PostModel.find_by_name(name) if post: return post_schema.dump(post), 200 return {"message": gettext("post_not_found")}, 404
def delete(self, name: str): x = StoreModel.find_store_by_name(name) if x: x.delete() return {"message": (gettext("store_STORE_DELETED_MSG"))}
def patch(cls): users = UserModel.find_all_users() if not users: return {"message": gettext("user_not_found")}, 404 return {"users": user_list_schema.dump(users)}, 200
def delete(cls, user_id: int, offer_id: int): offer = OfferModel.find_by_id(offer_id) if offer: offer.delete_from_db() return {"message": gettext("offer_deleted")}, 200 return {"message": gettext("offer_not_found")}, 400
def post(cls): jti = get_jwt()['jti'] BLACKLIST.add(jti) return {'message': gettext("user_logged_out")}, 200
def get(self, user_name): curr_user = user_api.get_user_by_username(user_name) if not curr_user: return {"message": gettext("user_not_found")}, 404 return {'user_id' : str(curr_user['_id'])}, 200
def get(cls, username: str): user = UserModel.find_by_username(username) if not user: return {'message': gettext("user_not_found")}, 404 return user_schema.dump(user), 200
def send_sms(self) -> MessageInstance: text = gettext("user_sms_text_code").format( str(self.most_recent_confirmation.code)) return Twilio.send_sms(number="+351" + self.phone, body=text)
def delete(cls, username: str): user = UserModel.find_by_username(username) if not user: return {'message': gettext("user_not_found")}, 404 user.delete_from_db() return {'message': gettext("user_deleted")}, 200
def get(cls, name: str): store = StoreModel.find_by_name(name) if store: return store_schema.dump(store), 200 return {"message": gettext("store_not_found")}, 404
def is_amount_above_zero(self, value): if value <= 0: raise ValidationError(gettext("trade_amount_above_zero"))
def delete(cls, name: str): item = ItemModel.find_by_name(name) if item: item.delete_from_db() return {'message': gettext('item_deleted')}, 200 return {'message': gettext('item_not_found')}, 404
def post(cls): jti = get_raw_jwt()["jti"] user_id = get_jwt_identity() BLACKLIST.add(jti) return {"message": gettext("user_logged_out").format(user_id)}, 200