def create_products(): counter = 0 admin = Admin() product_ids = [] while counter < 5: product_ids.append(admin.create_product().get("product")["product_id"]) counter += 1 return product_ids
def admin_menu(): while True: # ---------------------admin menu ---------------------- try: admin_choice = input(""" A: Create new product B: Show all products C: Show all Factors D: Change user status E: Change password Q: Logout Please enter your choice number: """ ) except ArithmeticError: print('invalid input,enter your choice.\n') all_loggers.error("Exception occured, user enter invalid input", exc_info=True) except ValueError: print('invalid input,enter "A" or "B".\n') all_loggers.error( "Exception occured, user enter invalid input in menu", exc_info=True) except TypeError: print("enter suitable input") all_loggers.error("Exception occured, user enter invalid input", exc_info=True) else: if admin_choice == "a" or admin_choice == "A": print("please split items with | ") try: name, brand, barcode, price, amount = list( map( lambda x: x.strip(), input( "enter name, brand, barcode, price and amount " ).split("|"))) except ValueError: print('invalid input,enter true input.\n') all_loggers.error("product wasnt create") else: Admin.create_product(name, brand, barcode, price, amount) elif admin_choice == "b" or admin_choice == "B": Admin.check_inventory() elif admin_choice == "c" or admin_choice == "C": Admin.see_all_factor() elif admin_choice == "d" or admin_choice == "D": user_choice = input( "which user do you want to get out of block?\n please, select the name" ) Admin.activate_user(user_choice) elif admin_choice == "e" or admin_choice == "E": username = input("please enter your username: "******"enter your old password") new_password = input("what is new password:"******"Q" or admin_choice == "q": break # if use exit, system finished all program