diff --git a/src/postorius/templates/postorius/lists/confirm_remove_role.html b/src/postorius/templates/postorius/lists/confirm_remove_role.html
new file mode 100644
index 0000000..668a9b2
--- /dev/null
+++ b/src/postorius/templates/postorius/lists/confirm_remove_role.html
@@ -0,0 +1,14 @@
+{% extends "postorius/base.html" %}
+{% load url from future %}
+{% load i18n %}
+{% load nav_helpers %}
+
+{% block main %}
+
{% trans 'Confirm Remove Role' %}
+ {% trans "Are you sure you want to remove?" %}
+
+{% endblock main %}
diff --git a/src/postorius/templates/postorius/lists/members.html b/src/postorius/templates/postorius/lists/members.html
index 2d36343..89ab036 100644
--- a/src/postorius/templates/postorius/lists/members.html
+++ b/src/postorius/templates/postorius/lists/members.html
@@ -26,6 +26,7 @@
{{ member }} |
+ Delete
|
{% endfor %}
@@ -52,6 +53,7 @@
{{ member }} |
+ Delete
|
{% endfor %}
diff --git a/src/postorius/urls.py b/src/postorius/urls.py
index 4d38fe0..b2e8267 100644
--- a/src/postorius/urls.py
+++ b/src/postorius/urls.py
@@ -66,6 +66,8 @@
url(r'^held_messages$',
'list_held_messages',
name='list_held_messages'),
+ url(r'^(?P[^/]+)/(?P[^/]+)',
+ 'remove_role', name='remove_role'),
url(r'^settings/(?P[^/]+)?'
'(?:/(?P.*))?$',
'list_settings',
diff --git a/src/postorius/views/list.py b/src/postorius/views/list.py
index 09c66ca..787029d 100644
--- a/src/postorius/views/list.py
+++ b/src/postorius/views/list.py
@@ -556,7 +556,39 @@
context_instance=RequestContext(request))
-@login_required
-def membership_settings(request):
- """Display a list of all memberships.
+@user_passes_test(lambda u: u.is_superuser)
+def remove_role(request, fqdn_listname=None, role=None, address=None,
+ template='postorius/lists/confirm_remove_role.html'):
+ """Removes a list moderator or owner.
"""
+ try:
+ the_list = List.objects.get_or_404(fqdn_listname=fqdn_listname)
+ except MailmanApiError:
+ return utils.render_api_error(request)
+
+ if role == 'owner':
+ if address not in the_list.owners:
+ messages.error(request, _('The user {} is not a owner'.format(address)))
+ return redirect("list_members", the_list.fqdn_listname)
+ elif role == 'moderator':
+ if address not in the_list.moderators:
+ messages.error(request, _('The user {} is not a moderator'.format(address)))
+ return redirect("list_members", the_list.fqdn_listname)
+
+ if request.method == 'POST':
+ try:
+ the_list.remove_role(role, address)
+ except MailmanApiError:
+ return utils.render_api_error(request)
+ except HTTPError as e:
+ messages.error(request, _('The {0} could not be removed:'
+ ' {1}'.format(role, e.msg)))
+ return redirect("list_members", the_list.fqdn_listname)
+ messages.success(request,
+ _('The user {0} has been removed as {1}.'.format(address, role)))
+ return redirect("list_members", the_list.fqdn_listname)
+
+ return render_to_response(template,
+ {'role': role, 'address': address,
+ 'fqdn_listname': the_list.fqdn_listname},
+ context_instance=RequestContext(request))