Varun Sharma has proposed merging
lp:~varun/postorius/postorius_gsoc2013_modified into lp:postorius.
Requested reviews:
Florian Fuchs (flo-fuchs)
For more details, see:
https://code.launchpad.net/~varun/postorius/postorius_gsoc2013_modified/+merge/164480
Added deletion of user functionality for superusers. Added view user_delete to
views/user.py and template user_confirm_delete.html to templates/users. As per
the suggestions from florian and steve, i have improved few things from my last
merge request like handling of MailmanApiError and showing email id in
notification rather than display name which was not a mandatory field.
--
https://code.launchpad.net/~varun/postorius/postorius_gsoc2013_modified/+merge/164480
Your team Mailman Coders is subscribed to branch lp:postorius.
=== modified file 'src/postorius/templates/postorius/users/index.html'
--- src/postorius/templates/postorius/users/index.html 2013-03-29 22:04:06 +0000
+++ src/postorius/templates/postorius/users/index.html 2013-05-17 18:18:43 +0000
@@ -16,6 +16,7 @@
<tr>
<th>{% trans 'Email' %}</th>
<th>{% trans 'Display name' %}</th>
+ <th></th> <!-- header for delete user button -->
<!-- th>{% trans 'Web User' %}</th -->
<!--th>{% trans 'Mailman User' %}</th -->
</tr>
@@ -29,6 +30,9 @@
<td>
{{ mm_user.display_name }}
</td>
+ <td>
+ <a href="{{mm_user.user_id}}/delete" class="btn btn-mini btn-danger">Delete</a>
+ </td>
<!--td><i class="icon-ok"></i></td -->
<!--td><i class="icon-remove"></i></td -->
</tr>
=== added file 'src/postorius/templates/postorius/users/user_confirm_delete.html'
--- src/postorius/templates/postorius/users/user_confirm_delete.html 1970-01-01 00:00:00 +0000
+++ src/postorius/templates/postorius/users/user_confirm_delete.html 2013-05-17 18:18:43 +0000
@@ -0,0 +1,15 @@
+{% extends "postorius/base.html" %}
+{% load url from future %}
+{% load i18n %}
+{% load nav_helpers %}
+
+{% block main %}
+
+ <h1>{% trans 'Confirm Deletion' %}</h1>
+
+ <p>{% trans "Are you sure you want to permanently delete this user ?" %}</p>
+ <form action="{{submit_url}}" method="post"> {% csrf_token %}
+ <button class="btn btn-danger" type="submit">{% trans "Delete" %} {{ domain }}</button>
+ <a class="btn" href="{% url 'user_index' %}">{% trans "Cancel" %}</a>
+ </form>
+{% endblock main %}
=== modified file 'src/postorius/urls.py'
--- src/postorius/urls.py 2013-03-29 22:04:06 +0000
+++ src/postorius/urls.py 2013-05-17 18:18:43 +0000
@@ -87,5 +87,6 @@
url(r'^users/new/$', 'user_new', name='user_new'),
url(r'^users/(?P<user_id>[^/]+)/$',
UserSummaryView.as_view(), name='user_summary'),
+ url(r'^users/(?P<user_id>\d+)/delete$', 'user_delete', name='user_delete'),
url(r'^api/lists/$', 'api_list_index', name='api_list_index'),
) + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
=== modified file 'src/postorius/views/user.py'
--- src/postorius/views/user.py 2013-04-08 17:59:47 +0000
+++ src/postorius/views/user.py 2013-05-17 18:18:43 +0000
@@ -289,4 +289,32 @@
{'help_text':help_text,
'helpid':helpid},
context_instance=RequestContext(request))
-
+
+
+@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.
+ """
+ if request.method == 'POST':
+ try:
+ user_id = kwargs["user_id"]
+ try:
+ user = MailmanUser.objects.get(address=user_id)
+ except MailmanApiError:
+ return utils.render_api_error(request)
+ email_id = user.addresses[0]
+ user.delete()
+ messages.success(request,
+ _('The user %s has been deleted.' % email_id))
+ return redirect("user_index")
+ except HTTPError as e:
+ messages.error(request, _('The user could not be deleted:'
+ ' %s' % e.msg))
+ return redirect("user_index")
+
+ user_id = kwargs["user_id"]
+ submit_url = reverse('user_delete',
+ kwargs={'user_id': user_id})
+ return render_to_response(template,
+ {'user': request.user, 'submit_url': submit_url},
+ context_instance=RequestContext(request))
_______________________________________________
Mailman-coders mailing list
[email protected]
http://mail.python.org/mailman/listinfo/mailman-coders