From 72c10e15298aef311eed2aeb4774bf78029ea075 Mon Sep 17 00:00:00 2001 From: Javier Sánchez Parra Date: Wed, 27 Apr 2022 17:21:09 +0200 Subject: Add 'Delete user' to Users section Creates "Delete user" form. The user to be deleted is selected from the sidebar in Users section. --- ogcp/forms/auth.py | 9 ++++++++ ogcp/templates/auth/delete_user.html | 17 +++++++++++++++ ogcp/templates/users.html | 2 ++ ogcp/views.py | 40 +++++++++++++++++++++++++++++++++++- 4 files changed, 67 insertions(+), 1 deletion(-) create mode 100644 ogcp/templates/auth/delete_user.html diff --git a/ogcp/forms/auth.py b/ogcp/forms/auth.py index b10d8fe..edc5d9a 100644 --- a/ogcp/forms/auth.py +++ b/ogcp/forms/auth.py @@ -57,3 +57,12 @@ class UserForm(FlaskForm): submit_btn = SubmitField( label=_l('Submit') ) + + +class DeleteUserForm(FlaskForm): + username = HiddenField( + validators=[InputRequired()] + ) + submit_btn = SubmitField( + label=_l('Submit') + ) diff --git a/ogcp/templates/auth/delete_user.html b/ogcp/templates/auth/delete_user.html new file mode 100644 index 0000000..42301ae --- /dev/null +++ b/ogcp/templates/auth/delete_user.html @@ -0,0 +1,17 @@ +{% extends 'users.html' %} +{% import "bootstrap/wtf.html" as wtf %} + +{% set sidebar_state = 'disabled' %} +{% set btn_back = true %} + +{% block nav_user_edit %}active{% endblock %} +{% block content %} + +

{{_('Delete user {}').format(form.username.data)}}

+ +{{ wtf.quick_form(form, + action=url_for('user_delete_post'), + method='post', + button_map={'submit_btn':'primary'}) }} + +{% endblock %} diff --git a/ogcp/templates/users.html b/ogcp/templates/users.html index 6dd056b..bd8e450 100644 --- a/ogcp/templates/users.html +++ b/ogcp/templates/users.html @@ -28,6 +28,8 @@ form="usersForm" formaction="{{ url_for('user_add_get') }}" formmethod="get"> + {% if btn_back %}