def setting(self): # check for request # if post then validate and update if request.method == 'POST': if (request.form['type'] == 'credential'): username = request.form['username'] password = request.form['password'] if len(username) > 2 and len(password) > 2: if (username != current_user.username): exist = Employee.getByUsername(username) if isinstance(exist, Employee): self.view.setFlashMessage("fail", "Username already exists!") return self.view.render_employee_setting(current_user) current_user.username = username current_user.setPassword(password) current_user.update() self.view.setFlashMessage("success", "Successfully updated") else: self.view.setFlashMessage("fail", "Password must be greater than 2!") elif (request.form['type'] == 'visible'): current_user.visible = request.form['visible'] current_user.update() self.view.setFlashMessage("success", "Successfully updated") return self.view.render_employee_setting(current_user)