From ac7714b9974b7a6faee0f5fc1c72cb50cd0be3f3 Mon Sep 17 00:00:00 2001
From: rubenwardy
Date: Wed, 9 Dec 2020 19:50:11 +0000
Subject: [PATCH] Add account page to settings
---
app/blueprints/users/settings.py | 19 +++
app/templates/users/account.html | 73 ++++++++++
app/templates/users/delete.html | 2 +-
app/templates/users/profile_edit.html | 184 +++++++-------------------
4 files changed, 144 insertions(+), 134 deletions(-)
create mode 100644 app/templates/users/account.html
diff --git a/app/blueprints/users/settings.py b/app/blueprints/users/settings.py
index 52f95ae..8a6a3ba 100644
--- a/app/blueprints/users/settings.py
+++ b/app/blueprints/users/settings.py
@@ -17,6 +17,11 @@ def get_setting_tabs(user):
"title": "Edit Profile",
"url": url_for("users.profile_edit", username=user.username)
},
+ {
+ "id": "account",
+ "title": "Account and Security",
+ "url": url_for("users.account", username=user.username)
+ },
{
"id": "notifications",
"title": "Email and Notifications",
@@ -188,6 +193,20 @@ def email_notifications(username=None):
tabs=get_setting_tabs(user), current_tab="notifications")
+@bp.route("/users//settings/account/")
+@login_required
+def account(username):
+ user : User = User.query.filter_by(username=username).first()
+ if not user:
+ abort(404)
+
+ if not user.can_see_edit_profile(current_user):
+ flash("Permission denied", "danger")
+ return redirect(url_for("users.profile", username=username))
+
+ return render_template("users/account.html", user=user, form=form, tabs=get_setting_tabs(user), current_tab="account")
+
+
@bp.route("/users//delete/", methods=["GET", "POST"])
@rank_required(UserRank.ADMIN)
def delete(username):
diff --git a/app/templates/users/account.html b/app/templates/users/account.html
new file mode 100644
index 0000000..0491fbf
--- /dev/null
+++ b/app/templates/users/account.html
@@ -0,0 +1,73 @@
+{% extends "users/settings_base.html" %}
+
+{% block title %}
+ {{ _("Account and Security | %(username)s", username=user.username) }}
+{% endblock %}
+
+{% block pane %}
+{{ _("Account and Security") }}
+
+{{ _("Password") }}
+{% if user == current_user %}
+ {% if user.password %}
+ Change Password
+ {% else %}
+ Set Password
+ {% endif %}
+{% else %}
+ {% if user.password %}
+ {{ _("Has password") }}
+ {% else %}
+ {{ _("Doesn't have password") }}
+ {% endif %}
+{% endif %}
+
+{{ _("Linked Accounts") }}
+
+
+{{ _("Account Deletion and Deactivation") }}
+
+{% if current_user.rank.atLeast(current_user.rank.ADMIN) %}
+ Delete or Deactivate
+{% else %}
+
+ {{ _("Account Deletion and Deactivation isn't available to users yet.") }}
+ {{ _("Please contact the admin.") }}
+
+{% endif %}
+
+{% endblock %}
diff --git a/app/templates/users/delete.html b/app/templates/users/delete.html
index 706621b..3aa0dd3 100644
--- a/app/templates/users/delete.html
+++ b/app/templates/users/delete.html
@@ -25,7 +25,7 @@
{% endif %}
- Cancel
+ Cancel
diff --git a/app/templates/users/profile_edit.html b/app/templates/users/profile_edit.html
index c47a4b5..05f105e 100644
--- a/app/templates/users/profile_edit.html
+++ b/app/templates/users/profile_edit.html
@@ -7,147 +7,65 @@
{% block pane %}
{{ _("Edit Profile") }}
-
-
-
-
-
- {% if user.forums_username %}
-
- {% endif %}
- {% if user.email %}
-
- Gravatar
-
- {% else %}
-
- Gravatar
-
- {% endif %}
-
+
{{ _("Profile Picture") }}
+
+
+
+ {% if user.forums_username %}
+
+ {% endif %}
+ {% if user.email %}
+
+ Gravatar
+
+ {% else %}
+
+ Gravatar
+
+ {% endif %}
-
-
-
- {% if user == current_user %}
-
- Password: |
-
- {% if user.password %}
- Set | Change
- {% else %}
- Not set | Set
- {% endif %}
- |
-
- {% endif %}
-
-
-
-
-
-
-
- Forums |
-
- {% if user.forums_username %}
-
- Connected
-
- {% elif user == current_user %}
- None
- {% endif %}
- |
-
-
- GitHub |
-
- {% if user.github_username %}
-
- Connected
-
-
- {% if user == current_user %}
-
- View ContentDB's GitHub Permissions
-
- {% endif %}
- {% elif user == current_user %}
- Link Github
- {% else %}
- None
- {% endif %}
- |
-
-
-
- {% if current_user.is_authenticated and current_user.rank.atLeast(current_user.rank.MODERATOR) %}
-
- Admin |
-
- {% if user.email %}
-
- Email
-
- {% else %}
-
- Email
-
- {% endif %}
- |
-
- {% endif %}
-
-
+
{{ _("Profile Information") }}
{% from "macros/forms.html" import render_field, render_submit_field %}
-
+
+ {{ render_submit_field(form.submit, tabindex=280) }}
+
+
{% endblock %}