Pavan Koli has proposed merging lp:~pskoli93/postorius/Add-a-member into 
lp:postorius.

Requested reviews:
  Mailman Coders (mailman-coders)
Related bugs:
  Bug #1444699 in Postorius: "I can't add a single member (non-owner, 
non-moderator) from the Members page."
  https://bugs.launchpad.net/postorius/+bug/1444699

For more details, see:
https://code.launchpad.net/~pskoli93/postorius/Add-a-member/+merge/257456

Option to add a single member was previously missing as pointed in the bug 
report, that option has been now added.
-- 
Your team Mailman Coders is requested to review the proposed merge of 
lp:~pskoli93/postorius/Add-a-member into lp:postorius.
=== modified file 'src/postorius/forms.py'
--- src/postorius/forms.py	2015-04-17 21:51:29 +0000
+++ src/postorius/forms.py	2015-04-25 08:32:24 +0000
@@ -91,6 +91,14 @@
             'required': _('Please enter an email adddress.'),
             'invalid': _('Please enter a valid email adddress.')})
 
+class NewSubscriberForm(forms.Form):
+
+    """Add a subscriber."""
+    subscriber_email = forms.EmailField(
+        label=_('Email Address'),
+        error_messages={
+            'required': _('Please enter an email adddress.'),
+            'invalid': _('Please enter a valid email adddress.')})
 
 class ListNew(FieldsetForm):
 

=== modified file 'src/postorius/templates/postorius/lists/members.html'
--- src/postorius/templates/postorius/lists/members.html	2015-04-16 18:19:33 +0000
+++ src/postorius/templates/postorius/lists/members.html	2015-04-25 08:32:24 +0000
@@ -65,6 +65,17 @@
     </table>
 
     <h2>{% trans "Members" %}</h2>
+    <form action="{% url 'list_members' list.fqdn_listname %}" method="POST" class="form-inline">{% csrf_token %}
+        <label for="bla">{% trans 'Email Address' %}</label>
+        {{ subscriber_form.subscriber_email }}
+        <button type="submit" class="btn">{% trans 'Add Member' %}</button>
+    </form>
+		<thead>
+    		<tr>
+    			<th>{% trans 'Address' %}</th>
+                <th>&nbsp;</th>
+    		</tr>
+        </thead>
     <table class="table table-bordered table-striped">
         <thead>
     		<tr>

=== modified file 'src/postorius/views/list.py'
--- src/postorius/views/list.py	2015-04-17 21:51:29 +0000
+++ src/postorius/views/list.py	2015-04-25 08:32:24 +0000
@@ -80,22 +80,40 @@
                                    % request.POST['moderator_email']))
                 except HTTPError as e:
                     messages.error(request, _(e.msg))
+        if 'subscriber_email' in request.POST:
+            subscriber_form = NewSubscriberForm(request.POST)
+            if subscriber_form.is_valid():
+                try:
+                    self.mailing_list.subscribe(
+                        subscriber_form.cleaned_data['subscriber_email'], pre_verified=True,
+                                                pre_confirmed=True)
+                    messages.success(
+                        request,
+                        _('The address %s has been subscribed to %s.' %
+                        (request.POST['subscriber_email'], self.mailing_list.fqdn_listname)))
+                except HTTPError as e:
+                    messages.error(request, _(e.msg))
+            return redirect('list_members', self.mailing_list.list_id)
         owner_form = NewOwnerForm()
         moderator_form = NewModeratorForm()
+        subscriber_form = NewSubscriberForm()
         return render_to_response('postorius/lists/members.html',
                                   {'list': self.mailing_list,
                                    'owner_form': owner_form,
-                                   'moderator_form': moderator_form},
+                                   'moderator_form': moderator_form,
+                                   'subscriber_form': subscriber_form},
                                   context_instance=RequestContext(request))
 
     @method_decorator(list_owner_required)
     def get(self, request, list_id, page=1):
         owner_form = NewOwnerForm()
         moderator_form = NewModeratorForm()
+        subscriber_form = NewSubscriberForm()
         return render_to_response('postorius/lists/members.html',
                                   {'list': self.mailing_list,
                                    'owner_form': owner_form,
-                                   'moderator_form': moderator_form},
+                                   'moderator_form': moderator_form,
+                                   'subscriber_form': subscriber_form},
                                   context_instance=RequestContext(request))
 
 

_______________________________________________
Mailman-coders mailing list
[email protected]
https://mail.python.org/mailman/listinfo/mailman-coders

Reply via email to