diff --git a/src/postorius/templates/postorius/users/user_confirm_delete.html b/src/postorius/templates/postorius/users/user_confirm_delete.html index e9376af..28cec57 100644 --- a/src/postorius/templates/postorius/users/user_confirm_delete.html +++ b/src/postorius/templates/postorius/users/user_confirm_delete.html @@ -6,7 +6,7 @@ {% block main %}
{% trans "Are you sure you want to permanently delete this user ?" %}
- diff --git a/src/postorius/views/user.py b/src/postorius/views/user.py index 97b5b5b..a5acb5c 100644 --- a/src/postorius/views/user.py +++ b/src/postorius/views/user.py @@ -205,17 +205,15 @@ @user_passes_test(lambda u: u.is_superuser) -def user_delete(request,template='postorius/users/user_confirm_delete.html',**kwargs): - """ Deletes a user after asking for confirmation. +def user_delete(request, user_id, + template='postorius/users/user_confirm_delete.html'): + """ Deletes a user upon confirmation. """ - user_id = kwargs["user_id"] try: mm_user = MailmanUser.objects.get_or_404(address=user_id) + email_id = mm_user.addresses[0] except MailmanApiError: return utils.render_api_error(request) - - try: - email_id = mm_user.addresses[0] except IndexError: email_id = '' if request.method == 'POST': @@ -226,13 +224,10 @@ except HTTPError as e: messages.error(request, _('The user could not be deleted:' ' %s' % e.msg)) + return redirect("user_index") messages.success(request, _('The user %s has been deleted.' % email_id)) return redirect("user_index") - - submit_url = reverse('user_delete', - kwargs={'user_id': user_id}) return render_to_response(template, - {'user': request.user, 'submit_url': submit_url,'email_id':email_id}, + {'user_id': user_id, 'email_id': email_id}, context_instance=RequestContext(request)) -