aboutsummaryrefslogtreecommitdiff
path: root/src/web/views
diff options
context:
space:
mode:
authorCédric Bonhomme <cedric@cedricbonhomme.org>2016-04-07 10:54:12 +0200
committerCédric Bonhomme <cedric@cedricbonhomme.org>2016-04-07 10:54:12 +0200
commite9be14b09ad60e406ddc264f5cd550360ff44bb5 (patch)
tree25f489bfd289dc8ca4404b8c0e26d7d0553a8dee /src/web/views
parentSend an email for the account confirmation. (diff)
downloadnewspipe-e9be14b09ad60e406ddc264f5cd550360ff44bb5.tar.gz
newspipe-e9be14b09ad60e406ddc264f5cd550360ff44bb5.tar.bz2
newspipe-e9be14b09ad60e406ddc264f5cd550360ff44bb5.zip
delete a user
Diffstat (limited to 'src/web/views')
-rw-r--r--src/web/views/admin.py21
1 files changed, 19 insertions, 2 deletions
diff --git a/src/web/views/admin.py b/src/web/views/admin.py
index 1dc676de..05159807 100644
--- a/src/web/views/admin.py
+++ b/src/web/views/admin.py
@@ -98,6 +98,23 @@ def process_user_form(user_id=None):
return redirect(url_for('admin.user_form', user_id=user.id))
+@admin_bp.route('/delete_user/<int:user_id>', methods=['GET'])
+@login_required
+@admin_permission.require(http_exception=403)
+def delete_user(user_id=None):
+ """
+ Delete a user (with all its data).
+ """
+ try:
+ user = UserController().delete(user_id)
+ flash(gettext('User %(nick)s successfully deleted',
+ nick=user.nickname), 'success')
+ except Exception as error:
+ flash(gettext('An error occured while trying to delete a user: '
+ '%(error)', error=error), 'danger')
+ return redirect(redirect_url())
+
+
@admin_bp.route('/toggle_user/<int:user_id>', methods=['GET'])
@login_required
@admin_permission.require()
@@ -116,7 +133,7 @@ def toggle_user(user_id=None):
else:
act_txt = 'activated' if user.is_active else 'desactivated'
- message = gettext('User %(login)s successfully %(is_active)s',
- login=user.login, is_active=act_txt)
+ message = gettext('User %(nickname)s successfully %(is_active)s',
+ login=user.nickname, is_active=act_txt)
flash(message, 'success')
return redirect(url_for('admin.dashboard'))
bgstack15