def logged_menu(logged_user): print("Welcome you are logged in as: " + logged_user.get_username()) while True: command = input("Logged>>") if command == 'info': print("You are: " + logged_user.get_username()) print("Your id is: " + str(logged_user.get_id())) print("Your balance is:" + str(logged_user.get_balance()) + '$') elif command == 'changepass': new_pass = input("Enter your new password: "******"Enter your new message: ") sql_manager.change_message(new_message, logged_user) elif command == 'show-message': print(logged_user.get_message()) elif command == 'balance': sql_manager.balance(logged_user.get_username()) elif command == 'Deposit': sql_manager.deposit(logged_user.get_username()) elif command == 'Withdraw': sql_manager.withdraw(logged_user.get_username()) elif command == 'help': print("info - for showing account info") print("changepass - for changing passowrd") print("change-message - for changing users message") print("show-message - for showing users message")
def test_deposit_withdraw(self): logged_user = sql_manager.login('Tester', '123Ab#78') sql_manager.deposit(10000, sql_manager.get_tan(logged_user)[0], logged_user) self.assertEqual(sql_manager.display_balance(logged_user), 10000.00) sql_manager.withdraw(1000, sql_manager.get_tan(logged_user)[1], logged_user) self.assertEqual(sql_manager.display_balance(logged_user), 9000.00)
def logged_menu(logged_user): print("Welcome you are logged in as: " + logged_user.get_username()) while True: command = input("Logged>>") if command == 'info': print("You are: " + logged_user.get_username()) print("Your id is: " + str(logged_user.get_id())) print("Your balance is:" + str(logged_user.get_balance()) + '$') elif command == 'changepass': new_pass = getpass.getpass(prompt='Password: '******'deposit': amount = input("Enter amount: ") tan_code = input("Enter your TAN code: ") if sql_manager.use_tan(logged_user, tan_code): if logged_user.deposit(float(amount)): new_balance = logged_user.get_balance() sql_manager.deposit(logged_user, new_balance) print("Deposited %s$ succesfully." % amount) elif command == 'withdraw': amount = input("Enter amount: ") tan_code = input("Enter your TAN code: ") if sql_manager.use_tan(logged_user, tan_code): if logged_user.withdraw(float(amount)): new_balance = logged_user.get_balance() sql_manager.withdraw(logged_user, new_balance) print("Withdrew %s$ succesfully." % amount) elif command == 'get-tan': password = getpass.getpass(prompt='Enter your password again please: ') if sql_manager.validate_password(logged_user, password): sql_manager.get_tan(logged_user) else: print("Invalid password.") elif command == 'change-message': new_message = input("Enter your new message: ") sql_manager.change_message(new_message, logged_user) elif command == 'show-message': print(logged_user.get_message()) elif command == 'logout': print("Goodbye %s!" % logged_user.get_username()) break elif command == 'help': print("info - for showing account info") print("changepass - for changing passowrd") print("change-message - for changing users message") print("show-message - for showing users message")
def logged_menu(logged_user): print("Welcome you are logged in as: " + logged_user.get_username()) while True: command = input("Logged>>").split(" ") if command[0] == 'info': print("You are: " + logged_user.get_username()) print("Your id is: " + str(logged_user.get_id())) print("Your balance is:" + str(logged_user.get_balance()) + '$') elif command[0] == 'changepass': new_pass = getpass.getpass("Enter your new password: "******"Password is not strong enough!") new_pass = getpass.getpass("Enter your new password: "******"Enter your new message: ") sql_manager.change_message(new_message, logged_user) elif command[0] == 'show-message': print(logged_user.get_message()) elif command[0] == "deposit" and len(command) > 1 and command[1].isdecimal(): amount = int(command[1]) sql_manager.deposit(logged_user.get_username(), amount) logged_user.deposit(amount) elif command[0] == "withdraw" and len(command) > 1 and command[1].isdecimal(): amount = int(command[1]) if amount > logged_user.get_balance(): print("Insufficient funds") else: logged_user.withdraw(amount) sql_manager.withdraw(logged_user.get_username(), amount) elif command[0] == "display-balance": print("Balance: {}".format(logged_user.get_balance())) elif command[0] == "logout": break elif command[0] == 'help': print("info - for showing account info") print("changepass - for changing passowrd") print("change-message - for changing users message") print("show-message - for showing users message") print("deposit <amount> - deposits <amount>") print("withdraw <amount> - withdraws <amount>") print("display-balance - displays balance") print("logout - to logout")
def logged_menu(logged_user): print("Welcome you are logged in as: " + logged_user.get_username()) while True: command = input("Logged>>") if command == 'info': print("You are: " + logged_user.get_username()) print("Your id is: " + str(logged_user.get_id())) print("Your balance is:" + str(logged_user.get_balance()) + '$') elif command == 'changepass': new_pass = getpass.getpass("Enter your new password: "******"Enter your new message: ") sql_manager.change_message(new_message, logged_user) elif command == 'show-message': print(logged_user.get_message()) elif command == 'deposit': amount = input("Enter the amount of money you want to deposit: ") tan = input("Enter TAN code: ") sql_manager.deposit(amount, tan, logged_user) elif command == 'withdraw': amount = input("Enter the amount of money you want to withdraw: ") tan = input("Enter TAN code: ") sql_manager.withdraw(amount, tan, logged_user) elif command == 'display-balance': print(sql_manager.display_balance(logged_user)) elif command == 'get-tan': sql_manager.get_tan(logged_user) elif command == 'help': print("info - for showing account info") print("changepass - for changing passowrd") print("change-message - for changing users message") print("show-message - for showing users message") print("deposit - to deposit into your account") print("withdraw - to withdraw from your account") print("display-balance - to display your current balance") print("get-tan - to send TAN codes to your email, you need " \ "them to make a deposit or to withdraw!") print("logout - to return to the main menu") elif command == 'logout': break
def logged_menu(logged_user): print("Welcome you are logged in as: " + logged_user.get_username()) while True: command = input("Logged>>") if command == "info": print("You are: " + logged_user.get_username()) print("Your id is: " + str(logged_user.get_id())) print("Your balance is:" + str(logged_user.get_balance()) + "$") elif command == "changepass": new_pass = getpass.getpass("Enter your new password: "******"change-message": new_message = input("Enter your new message: ") sql_manager.change_message(new_message, logged_user) elif command == "show-message": print(logged_user.get_message()) elif command == "deposit": amount = input("Enter the amount of money you want to deposit: ") tan = input("Enter TAN code: ") sql_manager.deposit(amount, tan, logged_user) elif command == "withdraw": amount = input("Enter the amount of money you want to withdraw: ") tan = input("Enter TAN code: ") sql_manager.withdraw(amount, tan, logged_user) elif command == "display-balance": print(sql_manager.display_balance(logged_user)) elif command == "get-tan": sql_manager.get_tan(logged_user) elif command == "help": print("info - for showing account info") print("changepass - for changing passowrd") print("change-message - for changing users message") print("show-message - for showing users message") print("deposit - to deposit into your account") print("withdraw - to withdraw from your account") print("display-balance - to display your current balance") print("get-tan - to send TAN codes to your email, you need " "them to make a deposit or to withdraw!") print("logout - to return to the main menu") elif command == "logout": break
def logged_menu(logged_user): while True: print('''Hi, {} Now you have the following options: 1) Info 2) Change pass 3) Show message 4) Change message 5) DEPOSIT MONEY 6) WITHDRAW MONEY 7) DISPLAY CURRENT BALANCE 8) Help 9) log out '''.format(logged_user.get_username())) choice = int(input("Choose an option: ")) if choice == 1: os.system('clear') print("You are: " + logged_user.get_username()) print("Your id is: " + str(logged_user.get_id())) print("Your balance is:" + str(logged_user.get_balance()) + '$') elif choice == 2: new_pass = getpass.getpass("Enter your new password: "******"Enter your new password again!: ") if new_pass == verify_pass and validate_pass( new_pass, logged_user.get_username()): sql_manager.change_pass(new_pass, logged_user) else: print("Invalid password") elif choice == 3: os.system('clear') print(logged_user.get_message()) elif choice == 4: os.system('clear') new_message = input("Enter your new message: ") sql_manager.change_message(new_message, logged_user) elif choice == 5: amount = input("How much do you want to deposit?") sql_manager.deposit(amount, logged_user) print("You have successfully added {} $ to your account".format( amount)) elif choice == 6: os.system('clear') amount = input("How much do you want to withdraw: ") if sql_manager.withdraw(amount): print("Here are your {} $".format(amount)) else: print("You don't have that kind of money") elif choice == 7: os.system('clear') print("Your balance is:" + str(logged_user.get_balance()) + '$') elif choice == 8: print('''Info - for showing account info Change pass - for changing passowrd Change message - for changing users message Show message - for showing users message ''') elif choice == 9: break
def logged_menu(logged_user): print("Welcome you are logged in as: " + logged_user.get_username()) while True: command = input("Logged>>") if command == 'info': print("You are: " + logged_user.get_username()) print("Your id is: " + str(logged_user.get_id())) print("Your balance is:" + str(logged_user.get_balance()) + '$') elif command == 'changepass': new_pass = getpass.getpass("Enter your new password: "******"Enter your new message: ") sql_manager.change_message(new_message, logged_user) elif command == 'show-message': print(logged_user.get_message()) elif command == 'deposit': amount = input("amount>") sql_manager.deposit(logged_user.get_username(), amount) elif command == 'withdraw': amount = input("amount>") sql_manager.withdraw(logged_user.get_username(), amount) elif command == 'balance': print(sql_manager.balance(str(logged_user.get_username()))) elif command == 'show clients': sql_manager.show_clients() elif command == 'help': print("info - for showing account info") print("changepass - for changing passowrd") print("change-message - for changing users message") print("show-message - for showing users message") print("deposit - for depositting money") print("withdraw - for withdrowing money") print("balance - for showing balance")
def logged_menu(logged_user): print("Welcome you are logged in as: " + logged_user.get_username()) while True: command = input("Logged>>") if command == 'info': print("You are: " + logged_user.get_username()) print("Your id is: " + str(logged_user.get_id())) print("Your balance is:" + str(logged_user.get_balance()) + '$') elif command == 'changepass': new_pass = getpass.getpass() sql_manager.change_pass(new_pass, logged_user) elif command == 'change-message': new_message = input("Enter your new message: ") sql_manager.change_message(new_message, logged_user) elif command == 'show-message': print(logged_user.get_message()) elif command == 'help': print("info - for showing account info") print("changepass - for changing passowrd") print("change-message - for changing users message") print("show-message - for showing users message") elif command == 'deposit': amount = input('Enter amount: ') tan = input('Enter code: ') print(sql_manager.deposit(logged_user.get_username(), amount, tan)) elif command == 'withdraw': amount = input('Enter amount: ') tan = input('Enter code: ') print(sql_manager.withdraw(logged_user.get_username(), amount.tan)) elif command == 'display': print(sql_manager.get_balance(logged_user.get_username())) elif command == 'get-tan': password = getpass.getpass() print( sql_manager.generate_tan_codes(logged_user.get_username(), password)) else: print("Not a valid command")
def logged_menu(logged_user): print("Welcome you are logged in as: " + logged_user.get_username()) while True: command = input("Logged>>") if command == 'info': print("You are: " + logged_user.get_username()) print("Your id is: " + str(logged_user.get_id())) print("Your balance is:" + str(logged_user.get_balance()) + '$') elif command == 'changepass': new_pass = getpass.getpass() sql_manager.change_pass(new_pass, logged_user) elif command == 'change-message': new_message = input("Enter your new message: ") sql_manager.change_message(new_message, logged_user) elif command == 'show-message': print(logged_user.get_message()) elif command == 'help': print("info - for showing account info") print("changepass - for changing passowrd") print("change-message - for changing users message") print("show-message - for showing users message") elif command == 'deposit': amount = input('Enter amount: ') tan = input('Enter code: ') print(sql_manager.deposit(logged_user.get_username(), amount, tan)) elif command == 'withdraw': amount = input('Enter amount: ') tan = input('Enter code: ') print(sql_manager.withdraw(logged_user.get_username(), amount. tan)) elif command == 'display': print(sql_manager.get_balance(logged_user.get_username())) elif command == 'get-tan': password = getpass.getpass() print(sql_manager.generate_tan_codes(logged_user.get_username(), password)) else: print("Not a valid command")
def test_withdraw(self): sql_manager.deposit('Tester', 200) sql_manager.withdraw('Tester', 50) self.assertEqual(sql_manager.balance('Tester'), 'your balance is 150.0')
def logged_menu(logged_user): print("Welcome you are logged in as: " + logged_user.get_username()) while True: command = input("Logged>>") #command = 'get-tan' username = logged_user.get_username() if command == 'info': print("You are: " + logged_user.get_username()) print("Your id is: " + str(logged_user.get_id())) print("Your balance is:" + str(logged_user.get_balance()) + '$') elif command == 'changepass': new_pass = input("Enter your new password: "******"Enter your new message: ") sql_manager.change_message(new_message, logged_user) elif command == 'show-message': print(logged_user.get_message()) elif command == 'deposit': money = int(input('Enter amount:')) tan = input('Enter TAN code:') if tan in sql_manager.get_user_unused_tans(username): sql_manager.deposit(username, money) print('Transaction successful!') print('{} were deposited to the bank'.format(money)) sql_manager.mark_tan_as_used(tan) else: print('Wrong TAN code!') elif command == 'withdraw': money = int(input('Enter amount:')) tan = input('Enter TAN code:') if tan in sql_manager.get_user_unused_tans(username): if sql_manager.withdraw(username, money): print('Transaction successful!') print('{} were withdrawed from the bank'.format(money)) else: print('Withdraw failed. Not enough money!') sql_manager.mark_tan_as_used(tan) else: print('Wrong TAN code!') elif command == 'display_balance': print('You have {} $ in your account'.format( logged_user.get_balance())) elif command == 'get-tan': unused_tans = sql_manager.get_user_unused_tans(username) if unused_tans: print('You have {} remaining TAN codes to use!'.format( len(unused_tans))) else: password_correct = False while not password_correct: password = getpass.getpass() password_correct = sql_manager.is_password_correct( username, password) if not password_correct: print('Incorrect password!') tans = sql_manager.generate_tans(username) desc_msg = 'You can use these 10 TANS in order to perform a transaction:' tans.insert(0, desc_msg) message = '\n'.join(tans) subject = 'TAN codes' send_email(username, subject, message) elif command == 'help': print("info - for showing account info") print("changepass - for changing passowrd") print("change-message - for changing users message") print("show-message - for showing users message")
def test_withdraw(self): sql_manager.deposit("Tester", 100) sql_manager.withdraw("Tester", 10) new_balance = sql_manager.get_balance("Tester") self.assertEqual(new_balance, 90.0)