diff options
author | Alejandro Sirgo Rica <asirgo@soleta.eu> | 2024-06-27 10:46:15 +0200 |
---|---|---|
committer | Alejandro Sirgo Rica <asirgo@soleta.eu> | 2024-06-28 08:43:20 +0200 |
commit | 50dbc817062f21bcd8a483d57def1a4cb13dcb80 (patch) | |
tree | 291bf16119fab5b22d52d97bcee2d07c625397d1 /ogcp/views.py | |
parent | 7d3567919aa6f51eeb53d4609621550750335476 (diff) |
views: notify user edit and user creation
Show a flash message when an user is created or edited successfully.
Diffstat (limited to 'ogcp/views.py')
-rw-r--r-- | ogcp/views.py | 12 |
1 files 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']) |