Ashish has proposed merging lp:~coolyashish/postorius/mass_unsubscribe into
lp:postorius.
Requested reviews:
Mailman Coders (mailman-coders)
For more details, see:
https://code.launchpad.net/~coolyashish/postorius/mass_unsubscribe/+merge/252943
This change adds feature of mass removal for admin/moderator in postorius
interface like mass subscription.
--
Your team Mailman Coders is requested to review the proposed merge of
lp:~coolyashish/postorius/mass_unsubscribe into lp:postorius.
=== added file 'src/postorius/templates/postorius/lists/mass_unsubscribe.html'
--- src/postorius/templates/postorius/lists/mass_unsubscribe.html 1970-01-01 00:00:00 +0000
+++ src/postorius/templates/postorius/lists/mass_unsubscribe.html 2015-03-13 19:22:28 +0000
@@ -0,0 +1,13 @@
+{% extends postorius_base_template %}
+{% load url from future %}
+{% load i18n %}
+{% load nav_helpers %}
+
+{% block main %}
+ {% list_nav 'mass_unsubscribe' "Mass UnSubscription" %}
+
+ <form action="{% url 'mass_unsubscribe' list.fqdn_listname %}" method="post" class="well"> {% csrf_token %}
+ {{ form.as_p }}
+ <button class="btn btn-primary" type="submit">{% trans "UnSubscribe users" %}</button>
+ </form>
+{% endblock main %}
=== modified file 'src/postorius/templates/postorius/menu/list_nav.html'
--- src/postorius/templates/postorius/menu/list_nav.html 2015-01-19 15:03:09 +0000
+++ src/postorius/templates/postorius/menu/list_nav.html 2015-03-13 19:22:28 +0000
@@ -18,6 +18,9 @@
{% if user.is_superuser or user.is_list_moderator %}
<li class="mm_nav_item"><a class="{% nav_active_class current 'mass_subscribe' %}" href="{% url 'mass_subscribe' list.list_id %}">{% trans "Mass Subscribe" %}</a></li>
{% endif %}
+ {% if user.is_superuser or user.is_list_moderator %}
+ <li class="mm_nav_item"><a class="{% nav_active_class current 'mass_unsubscribe' %}" href="{% url 'mass_unsubscribe' list.list_id %}">{% trans "Mass UnSubscribe" %}</a></li>
+ {% endif %}
{% if user.is_superuser or user.is_list_owner %}
<li class="mm_nav_item"><a class="{% nav_active_class current 'list_delete' %}" href="{% url 'list_delete' list.list_id %}">{% trans "Delete List" %}</a></li>
{% endif %}
=== modified file 'src/postorius/urls.py'
--- src/postorius/urls.py 2015-02-09 14:35:44 +0000
+++ src/postorius/urls.py 2015-03-13 19:22:28 +0000
@@ -53,6 +53,9 @@
url(r'^mass_subscribe/$',
ListMassSubsribeView.as_view(
), name='mass_subscribe'),
+ url(r'^mass_unsubscribe/$',
+ ListMassUnSubscribeView.as_view(
+ ), name='mass_unsubscribe'),
url(r'^delete$',
'list_delete', name='list_delete'),
url(r'^held_messages/(?P<msg_id>[^/]+)/'
=== modified file 'src/postorius/views/list.py'
--- src/postorius/views/list.py 2015-02-09 14:35:44 +0000
+++ src/postorius/views/list.py 2015-03-13 19:22:28 +0000
@@ -268,6 +268,44 @@
return redirect('mass_subscribe', self.mailing_list.list_id)
+class ListMassUnSubscribeView(MailingListView):
+
+ """Mass Unsubscription."""
+
+ @method_decorator(list_owner_required)
+ def get(self, request, *args, **kwargs):
+ form = ListMassSubscription()
+ form.fields['emails'].label = "Emails to mass unsubscribe"
+ return render_to_response('postorius/lists/mass_unsubscribe.html',
+ {'form': form, 'list': self.mailing_list},
+ context_instance=RequestContext(request))
+
+ def post(self, request, *args, **kwargs):
+ form = ListMassSubscription(request.POST)
+ if not form.is_valid():
+ messages.error(request, 'Please fill out the form correctly.')
+ else:
+ emails = request.POST["emails"].splitlines()
+ for email in emails:
+ parts = email.split('@')
+ if len(parts) != 2 or '.' not in parts[1]:
+ messages.error(request,
+ 'The email address %s is not valid.' %
+ email)
+ else:
+ try:
+ self.mailing_list.unsubscribe(email)
+ messages.success(
+ request,
+ 'The address %s has been unsubscribed to %s.' %
+ (email, self.mailing_list.fqdn_listname))
+ except MailmanApiError:
+ return utils.render_api_error(request)
+ except HTTPError, e:
+ messages.error(request, e)
+ return redirect('mass_unsubscribe', self.mailing_list.list_id)
+
+
def _get_choosable_domains(request):
try:
domains = Domain.objects.all()
_______________________________________________
Mailman-coders mailing list
[email protected]
https://mail.python.org/mailman/listinfo/mailman-coders