Пример #1
0
def update_code_shopping_cart(username, item_id, code):
    if username is not None and item_id is not None and code is not None:
        user = RegisteredUsers.get_user(username)
        if user is not False:
            if len(code) == 15 and isinstance(code, str):
                return ShoppingCartDB.update_code_shopping_cart(
                    username, item_id, code)
    return False
Пример #2
0
def add_all_shopping_cart_to_user(shopping_cart):
    for cart_item in shopping_cart:
        status = ShoppingCartDB.add_item_shopping_cart(cart_item)
        if status is False:
            return False
        if cart_item.code is not None:
            status = ShoppingCartDB.update_code_shopping_cart(cart_item.username, cart_item.item_id, cart_item.code)
            if status is False:
                return False

    return True