I am struggling to update my users in my update function. 1.The first if: is for making sure the user doesnt forget to input the user name. 2.the else: is to ensure the user input the correct username, 3.then the user can choose what to update between fist and last name, and the password.
But it now only 1 and 2 are working, then when I try to update the first, last or pwd.. it is not updating
def update_user(self, first, last, user, pwd, des):
pwd = hashlib.sha256(pwd.encode()).hexdigest()
if user == '':
self.notify.add_widget(Label(text='[color=#FF0000][b]All Fields Required[/b][/color]',markup=True))
self.notify.open()
Clock.schedule_once(self.killswitch,1)
else:
user = self.user.find_one({'user_name':user})
if user == None:
self.notify.add_widget(Label(text='[color=#FF0000][b]Invalid Username[/b][/color]',markup=True))
self.notify.open()
Clock.schedule_once(self.killswitch,1)
else:
if first == '':
first = user['first_name']
if last == '':
last = user['last_name']
if pwd == '':
pwd = user['password']
self.user.update_one({'user_name':user},{'$set':{'first_name':first,'last_name':last,'user_name':user,'password':pwd,'designation':des,'date':datetime.now()}})
content = self.ids.scn_content
content.clear_widgets()
users = self.get_users()
userstable = DataTable(table=users)
content.add_widget(userstable)