diff --git a/atst/app.py b/atst/app.py index 884d2bee..0cc2ca13 100644 --- a/atst/app.py +++ b/atst/app.py @@ -15,6 +15,7 @@ from atst.routes import bp from atst.routes.workspaces import bp as workspace_routes from atst.routes.requests import requests_bp from atst.routes.dev import bp as dev_routes +from atst.routes.users import bp as user_routes from atst.routes.errors import make_error_pages from atst.domain.authnid.crl import CRLCache from atst.domain.auth import apply_authentication @@ -57,6 +58,7 @@ def make_app(config): app.register_blueprint(bp) app.register_blueprint(workspace_routes) app.register_blueprint(requests_bp) + app.register_blueprint(user_routes) if ENV != "prod": app.register_blueprint(dev_routes) diff --git a/atst/models/user.py b/atst/models/user.py index 48570937..2c03b8a0 100644 --- a/atst/models/user.py +++ b/atst/models/user.py @@ -52,3 +52,10 @@ class User(Base, mixins.TimestampsMixin, mixins.AuditableMixin): self.has_workspaces, self.id, ) + + def to_dictionary(self): + return { + c.name: getattr(self, c.name) + for c in self.__table__.columns + if c.name not in ["id"] + } diff --git a/atst/routes/__init__.py b/atst/routes/__init__.py index c4b76de3..5051ad5a 100644 --- a/atst/routes/__init__.py +++ b/atst/routes/__init__.py @@ -10,7 +10,6 @@ from atst.domain.users import Users from atst.domain.authnid import AuthenticationContext from atst.domain.audit_log import AuditLog from atst.domain.auth import logout as _logout -from atst.forms.edit_user import EditUserForm bp = Blueprint("atst", __name__) @@ -119,19 +118,6 @@ def activity_history(): return render_template("audit_log.html", audit_events=audit_events) -@bp.route("/user") -def user(): - form = EditUserForm(request.form) - user = g.current_user - return render_template("user/edit.html", form=form, user=user) - - -@bp.route("/save_user") -def save_user(): - # no op - return redirect(url_for(".home")) - - @bp.route("/about") def about(): return render_template("about.html") diff --git a/atst/routes/users.py b/atst/routes/users.py new file mode 100644 index 00000000..2762421c --- /dev/null +++ b/atst/routes/users.py @@ -0,0 +1,17 @@ +from flask import Blueprint, render_template, g, redirect, session, url_for, request +from atst.forms.edit_user import EditUserForm + + +bp = Blueprint("users", __name__) + + +@bp.route("/user") +def user(): + user = g.current_user + form = EditUserForm(data=user.to_dictionary()) + return render_template("user/edit.html", form=form, user=user) + + +@bp.route("/user", methods=["POST"]) +def update_user(): + return redirect(url_for(".home")) diff --git a/templates/navigation/topbar.html b/templates/navigation/topbar.html index 6bcd0d0a..ceeefcfb 100644 --- a/templates/navigation/topbar.html +++ b/templates/navigation/topbar.html @@ -20,7 +20,7 @@ {% endif %} - + {{ g.current_user.first_name + " " + g.current_user.last_name }} {{ Icon('avatar', classes='topbar__link-icon') }} diff --git a/templates/user/edit.html b/templates/user/edit.html index 44cbc71f..9a26b115 100644 --- a/templates/user/edit.html +++ b/templates/user/edit.html @@ -1,12 +1,7 @@ {% extends "base.html" %} -{% from "components/alert.html" import Alert %} {% block content %}
- {{ Alert('This form does not yet function', - message="

Functionality of this form is pending more engineering work. Engineers, please remove this alert when done.

", - level='warning' - ) }}
@@ -17,7 +12,7 @@
- {% set form_action = url_for('atst.save_user') %} + {% set form_action = url_for('users.user') %} {% include "fragments/edit_user_form.html" %}