def update_phone(data=None, cls=True): render_template(context={}, template="add_phone.jinja2", cls=cls) phone = input() render_template(context={}, template="add_new_phone.jinja2", cls=cls) new_phone = input() Phone.update(phone, new_phone) return 51, None
def update_user_controller(data=None, cls=True): users = User.all() request = input( 'Введите 1, если хотите изменить имя; любую другую клавишу - если хотите изменить номер: ' ) if request == '1': render_template(context={'users': users}, template="update_name1.jinja2", cls=cls) old_name = input() new_name = input("Новое имя: ") user = User.update(old_name, new_name) return '1', user else: render_template(context={'users': users}, template="update_name2.jinja2", cls=cls) username = input( "Введите имя пользователя, чей номер Вы бы хотели изменить: ") phones = Phone.all() for i in range(len(users)): if users[i].name == username: numbers_line = '' for k in users[i].phones: numbers_line = numbers_line + k.phone + ' ' print( f'Номера, принадлежащие пользователю {users[i].name}: {numbers_line}' ) old_phone = input("Введите номер, который хотите изменить: ") new_phone = input("Новый номер: ") phone = Phone.update(old_phone, new_phone) return '1', phone
def update_user_controller(data=None, cls=True): users = User.all() choice = input('Enter n, if u want to change the name, enter p, if u want \ to change the phone number: ') if choice == 'n': render_template(context={'users': users}, template="update_name.jinja2", cls=cls) old_name = input() new_name = input("Ur new name: ") user = User.update(old_name, new_name) return '51', user if choice == 'p': render_template(context={'users': users}, template="user_delete.jinja2", cls=cls) username_upd = input("Enter user's name, that phone's u want to \ update: ") phones = Phone.all() for i in range(len(users)): if users[i].name == username_upd: numberline = '' for y in users[i].phones: numberline += y.phone + ' ' print(f'All numbers belonging to this user: \ {users[i].name}: {numberline}') old_phone = input("Enter the number, that u want to change: ") new_phone = input("Enter ur new number: ") phone = Phone.update(old_phone, new_phone) return '51', phone