From 50dbc817062f21bcd8a483d57def1a4cb13dcb80 Mon Sep 17 00:00:00 2001 From: Alejandro Sirgo Rica Date: Thu, 27 Jun 2024 10:46:15 +0200 Subject: views: notify user edit and user creation Show a flash message when an user is created or edited successfully. --- ogcp/views.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/ogcp/views.py b/ogcp/views.py index 93514a3..83a0e4d 100644 --- a/ogcp/views.py +++ b/ogcp/views.py @@ -3023,7 +3023,7 @@ def save_user(form, preserve_pwd): pwd_hash_confirm = hash_password(form.pwd_confirm.data) if not pwd_hash == pwd_hash_confirm: flash(_('Passwords do not match'), category='error') - return redirect(url_for('users')) + return False admin = form.admin.data scopes = form.scopes.data @@ -3085,7 +3085,7 @@ def save_user(form, preserve_pwd): app.config['USERS'].remove(old_user) app.config['USERS'].append(user) - return redirect(url_for('users')) + return True def delete_user(username): @@ -3127,7 +3127,9 @@ def user_add_post(): flash(_('This username already exists'), category='error') return redirect(url_for('users')) - return save_user(form, preserve_pwd=False) + if save_user(form, preserve_pwd=False): + flash(_('User created successfully'), category='info') + return redirect(url_for('users')) @app.route('/user/edit', methods=['GET']) @@ -3200,7 +3202,9 @@ def user_edit_post(): if preserve_pwd: form.pwd.data = old_user_data.get("PASS") - return save_user(form, preserve_pwd) + if save_user(form, preserve_pwd): + flash(_('User edited successfully'), category='info') + return redirect(url_for('users')) @app.route('/user/delete', methods=['GET']) -- cgit v1.2.3-18-g5258