Beispiel #1
0
    def up_user(self):
        '''
        updates a user selected details in the database and show a success popup
        '''
        # get the list box
        lb = self.list_box["users"]
        selection = lb.curselection()

        if (selection != ()):
            # get new parameters from entry widgets in the dictionaries
            new_role = self.entry_fields[self.labels[0]].get()
            new_name = self.entry_fields[self.labels[1]].get()
            new_email = self.entry_fields[self.labels[2]].get()

            verified = self.verify_user_input(new_role, new_name, new_email)

            if (verified):
                uid = lb.get(selection[0]).split()
                # otherwise update the database with new entries
                db.update_user_role(uid[0], new_role, conn)
                db.update_user_name(uid[0], new_name, conn)
                db.update_user_email(uid[0], new_email, conn)
                # get a string representation
                user_string = self.string_uid(uid[0])
                # clear the entry fields
                self.clear_entries()
                # update the list box
                lb.delete(selection[0])
                lb.insert(selection[0], user_string)
                # show popup
                showinfo("Success",
                         "User #" + str(uid[0]) + " has been updated")
Beispiel #2
0
 def up_user(self, button):
     '''
     delete a user details in the database and show a success popup
     '''        
     # get new parameters from entry widgets in the dictionaries
     new_role = self.roles[button].get()
     new_name = self.names[button].get()
     new_email = self.emails[button].get()
     # update the database with new entries
     db.update_user_role(button, new_role, conn)
     db.update_user_name(button, new_name, conn)
     db.update_user_email(button, new_email, conn)
     
     self.refresh()
     
     # show popup
     showinfo("Success", "User #" + str(button) + " has been updated")
Beispiel #3
0
 def up_user(self, button):
     '''
     delete a user details in the database and show a success popup
     '''        
     # get new parameters from entry widgets in the dictionaries
     new_role = self.roles[button].get()
     new_name = self.names[button].get()
     new_email = self.emails[button].get()
     
     # if any of the entries is blank, return a msg
     if ((new_role == '') or (new_name == '') or (new_email == '')) :
         return "blank entry"
     # if role is invalid return a msg
     if ((new_role != 'student') and (new_role != 'admin')) :
         return "invalid role"
     # otherwise update the database with new entries
     db.update_user_role(button, new_role, conn)
     db.update_user_name(button, new_name, conn)
     db.update_user_email(button, new_email, conn)
     
     self.refresh()
     
     # show popup
     showinfo("Success", "User #" + str(button) + " has been updated")