def editEmployee(self): """Finds an employee by username and returns the employee object. Used by flask-login to maintain a session Args: None. Flask request object is implicitly passed and accessed, however Returns: werkzeug.wrappers.Response: Flask response object for redirecting user. """ firstName = request.form['firstName'] lastName = request.form['lastName'] username = request.form['username'] email = request.form['email'] password = request.form['password'] if (password == ""): password = current_user.getCredentials().getPassword() userID = current_user.getNumericID() role = current_user.getRole() for user in zoo.getEmployees(): if (user.getNumericID() == userID): user.getContactInfo().setFirstName(firstName) user.getContactInfo().setLastName(lastName) user.getContactInfo().setEmail(email) user.getCredentials().setUsername(username) user.getCredentials().setPassword(password) return redirect(url_for('settings'))
def decorated_view(*args, **kwargs): if current_user.get_id() == None: return login_manager.unauthorized() if current_user.getRole() != role and role != 'ANY': return login_manager.unauthorized() return fn(*args, **kwargs)
def decorated_view(*args, **kwargs): if not (current_user and current_user.is_authenticated): return login_manager.unauthorized() acceptable_roles = set(("ANY", current_user.getRole())) if role not in acceptable_roles: return login_manager.unauthorized() return func(*args, **kwargs)
def index(): """Renders the homepage. Login required Args: None Returns: werkzeug.wrappers.Response: Flask response object for redirecting user. """ if (current_user.getRole() == "Zookeeper"): data = zooController.constructKeeperChart() return render_template("index.html", current_user=current_user, enclosure=current_user.getAssignedEnclosure(), data=data) else: data = zooController.constructVetChart() return render_template("index.html", current_user=current_user, animal=current_user.getAnimalTreating(), data=data)