aboutsummaryrefslogtreecommitdiff
path: root/src
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
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')
-rw-r--r--src/web/templates/admin/dashboard.html2
-rw-r--r--src/web/views/admin.py21
2 files changed, 20 insertions, 3 deletions
diff --git a/src/web/templates/admin/dashboard.html b/src/web/templates/admin/dashboard.html
index 925d4cac..6a0793ce 100644
--- a/src/web/templates/admin/dashboard.html
+++ b/src/web/templates/admin/dashboard.html
@@ -34,7 +34,7 @@
<i class="glyphicon glyphicon-ok-circle" title="{{ _("Enable this account") }}"></i>
{% endif %}
</a>
- <a href="{{ url_for("admin.toggle_user", user_id=user.id) }}"><i class="glyphicon glyphicon-remove" title="{{ _('Delete this user') }}" onclick="return confirm('{{ _('You are going to delete this account.') }}');"></i></a>
+ <a href="{{ url_for("admin.delete_user", user_id=user.id) }}"><i class="glyphicon glyphicon-remove" title="{{ _('Delete this user') }}" onclick="return confirm('{{ _('You are going to delete this account.') }}');"></i></a>
{% endif %}
</td>
</tr>
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