Bhavesh Goyal has proposed merging 
lp:~bhavesh-goyal093/postorius/feature-added-search-postorius-lists into 
lp:postorius.

Requested reviews:
  Mailman Coders (mailman-coders)

For more details, see:
https://code.launchpad.net/~bhavesh-goyal093/postorius/feature-added-search-postorius-lists/+merge/252274

Search is regarded as an important function for any list. The postorius lists 
earlier had no such function in members list page. Thus for large lists, it was 
difficult for list maintainer to search for a particular member in such lists. 
Even with Find In Page Browser function, it doesn't allow to search among whole 
lists across different pages and just highlights the results merely reducing 
the effort of going through the whole list.

Now The Members list can be filtered based on email address and certain 
functions such as getting all addresses starting with certain keywords and 
getting addresses containing some specific keywords can also be performed using 
the search box implemented in members list page. 
-- 
Your team Mailman Coders is requested to review the proposed merge of 
lp:~bhavesh-goyal093/postorius/feature-added-search-postorius-lists into 
lp:postorius.
=== modified file 'src/postorius/forms.py'
--- src/postorius/forms.py	2015-02-09 14:35:44 +0000
+++ src/postorius/forms.py	2015-03-09 12:25:32 +0000
@@ -95,7 +95,16 @@
             'required': _('Please enter an email adddress.'),
             'invalid': _('Please enter a valid email adddress.')})
 
-
+class NewMemberSearchForm(forms.Form):
+ 
+    """Search Among the list Members."""
+    search_name = forms.CharField(
+        label=_('Search Member Name'),
+	required=True,
+	error_messages={
+	    'required': _('Please enter a name for the member to be searched'),
+	    'invalid': _('Please enter a valid name')})
+	
 class ListNew(FieldsetForm):
 
     """

=== modified file 'src/postorius/static/postorius/css/style.css'
--- src/postorius/static/postorius/css/style.css	2015-02-06 15:50:56 +0000
+++ src/postorius/static/postorius/css/style.css	2015-03-09 12:25:32 +0000
@@ -192,7 +192,9 @@
 .btn {
     border-radius: 2px;
 }
-
+.clear{
+    margin-left: 0.2em;
+}	
 /* tables */
 .table .mm_action {
     text-align: right;
@@ -212,6 +214,9 @@
 }
 
 /* auto-generated forms made a bit cleaner */
+.well {
+    width: 100%;
+}
 .well label {
     display: inline;
 }

=== modified file 'src/postorius/templates/postorius/lists/members.html'
--- src/postorius/templates/postorius/lists/members.html	2015-01-17 17:23:59 +0000
+++ src/postorius/templates/postorius/lists/members.html	2015-03-09 12:25:32 +0000
@@ -60,9 +60,15 @@
     	</tbody>
     </table>
 
-    <h2>{% trans "Members" %}</h2>
-
-    <table class="table table-bordered table-striped">
+   <h2>{% trans "Members" %}</h2>
+   <form style="float:left" action="{% url 'list_members' list.fqdn_listname %}" method="POST" class="form-inline" >{% csrf_token %}
+       {{ search_form.search_name }}
+       <button type="submit" class="btn">{% trans 'Search' %}</button>
+   </form>
+   <form action="{% url 'list_members' list.fqdn_listname %}" method="POST" class="form-inline">{% csrf_token %}
+       <button type="submit" class="btn clear">{% trans 'Clear Filter' %}</button>
+   </form>
+<table class="table table-bordered table-striped">
         <thead>
     		<tr>
     			<th>{% trans 'Address' %}</th>
@@ -71,7 +77,7 @@
     		</tr>
         </thead>
     	<tbody>
-            {% for member in list.member_page %}
+            {% for member in search_res %}
                 <tr>
                     <td> <a href="{% url 'list_member_options' list.fqdn_listname member.email %}">
                         {{ member.email }}</a></td>

=== modified file 'src/postorius/templates/postorius/user_subscription_preferences.html'
--- src/postorius/templates/postorius/user_subscription_preferences.html	2015-01-09 16:07:56 +0000
+++ src/postorius/templates/postorius/user_subscription_preferences.html	2015-03-09 12:25:32 +0000
@@ -35,14 +35,34 @@
           <tr class = "{% cycle row1,row2 %}" >
           {% for form,subscription in zipped_data %}
              <td style="width:10%">{{subscription.list_id}}</td>
-             <td style="width:14%">{{form.delivery_status}}</td>
+	     <td style="width:14%"><table>
+        	{% for field in form.delivery_status %}
+            	<tr><td>{{ field }}</td></tr>
+        	{% endfor %}</table>
+	     </td>
              <td style="width:20%">{{form.delivery_mode}}</td>
-             <td style="width:14%">{{form.receive_own_postings}}</td>
-             <td style="width:14%">{{form.acknowledge_posts}}</td>
-             <td style="width:14%">{{form.hide_address}}</td>
-             <td style="width:14%">{{form.receive_list_copy}}</td>
-          </tr>
+	     <td style="width:14%"><table>
+        	{% for field in form.receive_own_postings %}
+            	<tr><td>{{ field }}</td></tr>
+        	{% endfor %}</table>
+	     </td>
+	     <td style="width:14%"><table>
+        	{% for field in form.acknowledge_posts %}
+            	<tr><td>{{ field }}</td></tr>
+        	{% endfor %}</table>
+	     </td>
+            <td style="width:14%"><table>
+		{% for field in form.hide_address %}
+            	<tr><td>{{ field }}</td></tr>
+        	{% endfor %}</table>
+	     </td>
+	     <td style="width:14%"><table>
+        	{% for field in form.receive_list_copy %}
+            	<tr><td>{{ field }}</td></tr>
+        	{% endfor %}</table>
+	     </td>
           {% endfor %}
+	  </tr>
        </table>
        <center><button class="btn btn-success" type="submit"> {% trans "Save" %}</button></center>
     </form>

=== 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-09 12:25:32 +0000
@@ -77,22 +77,50 @@
                                    % request.POST['moderator_email']))
                 except HTTPError as e:
                     messages.error(request, _(e.msg))
-        owner_form = NewOwnerForm()
+        if 'search_name' in request.POST:
+	    search_form = NewMemberSearchForm(request.POST)
+	    if search_form.is_valid():
+		res = []
+		mlist = self._get_list(list_id,page)
+                for names in mlist.member_page:
+                    if names.email.find(request.POST['search_name']) == 0:
+	                res.append(names)
+	        try:
+		    	if len(res) == 0:
+			    messages.success(
+			    request, _('No Result Found for string \' %s \'.' % request.POST['search_name']))
+			else:
+			    messages.success(
+	                    request, _('Found %s member(s) containing string \' %s \'.' % (len(res), request.POST['search_name'])))
+		except HTTPError as e:
+	            messages.error(request, _(e.msg))
+	try:
+	    res
+	except UnboundLocalError as e:
+	   res = self._get_list(list_id, page).member_page
+	owner_form = NewOwnerForm()
         moderator_form = NewModeratorForm()
+        search_form = NewMemberSearchForm()
         return render_to_response('postorius/lists/members.html',
                                   {'list': self.mailing_list,
                                    'owner_form': owner_form,
-                                   'moderator_form': moderator_form},
+                                   'moderator_form': moderator_form,
+				   'search_form': search_form,
+				   'search_res': res},
                                   context_instance=RequestContext(request))
 
     @method_decorator(list_owner_required)
     def get(self, request, list_id, page=1):
         owner_form = NewOwnerForm()
         moderator_form = NewModeratorForm()
+        search_form = NewMemberSearchForm()
+        res = self._get_list(list_id,page).member_page
         return render_to_response('postorius/lists/members.html',
                                   {'list': self.mailing_list,
                                    'owner_form': owner_form,
-                                   'moderator_form': moderator_form},
+                                   'moderator_form': moderator_form,
+				   'search_form': search_form,
+				   'search_res': res},
                                   context_instance=RequestContext(request))
 
 

_______________________________________________
Mailman-coders mailing list
Mailman-coders@python.org
https://mail.python.org/mailman/listinfo/mailman-coders

Reply via email to