Exemplo n.º 1
0
    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
Exemplo n.º 2
0
 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
Exemplo n.º 3
0
    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")}
Exemplo n.º 6
0
 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
Exemplo n.º 7
0
 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
Exemplo n.º 8
0
    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
Exemplo n.º 9
0
    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
Exemplo n.º 10
0
    def delete(cls, name: str):
        store = StoreModel.find_by_name(name)
        if store:
            store.delete_from_db()

        return {'message': gettext('store_deleted')}
Exemplo n.º 11
0
def postlogoutpage(user_id):
    return render_template("post_logout.html",
                           text=gettext("user_logged_out").format(user_id))
Exemplo n.º 12
0
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"))
Exemplo n.º 13
0
    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
Exemplo n.º 14
0
 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
Exemplo n.º 15
0
    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
Exemplo n.º 16
0
 def delete(self, name: str):
     x = StoreModel.find_store_by_name(name)
     if x:
         x.delete()
     return {"message": (gettext("store_STORE_DELETED_MSG"))}
Exemplo n.º 17
0
    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
Exemplo n.º 18
0
 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
Exemplo n.º 19
0
 def post(cls):
     jti = get_jwt()['jti']
     BLACKLIST.add(jti)
     return {'message': gettext("user_logged_out")}, 200
Exemplo n.º 20
0
    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
Exemplo n.º 21
0
 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
Exemplo n.º 22
0
 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)
Exemplo n.º 23
0
 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
Exemplo n.º 24
0
 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
Exemplo n.º 25
0
 def is_amount_above_zero(self, value):
     if value <= 0:
         raise ValidationError(gettext("trade_amount_above_zero"))
Exemplo n.º 26
0
 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
Exemplo n.º 27
0
 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