mango r266 - in branches/django: . mango www



Author: ovitters
Date: Fri Jun 27 20:40:05 2008
New Revision: 266
URL: http://svn.gnome.org/viewvc/mango?rev=266&view=rev

Log:
	* mango/views.py (list_foundationmembers): Allow filtering on
	foundation members (firstname, lastname, email and status).
	* www/list_foundationmembers.xsl: Adjust per above.


Modified:
   branches/django/   (props changed)
   branches/django/ChangeLog
   branches/django/mango/views.py
   branches/django/www/list_foundationmembers.xsl

Modified: branches/django/mango/views.py
==============================================================================
--- branches/django/mango/views.py	(original)
+++ branches/django/mango/views.py	Fri Jun 27 20:40:05 2008
@@ -4,6 +4,7 @@
 from django.db.models import Q
 from django.db.models.query import QuerySet
 from django.shortcuts import get_object_or_404
+
 import datetime
 
 import models
@@ -242,7 +243,35 @@
 def list_foundationmembers(request):
     doc, pagenode = get_xmldoc('List Foundation Members', request, 'listfoundationmembers')
 
-    queryset = models.Foundationmembers.objects.all()
+    filter, filternode = None, None
+
+    filter_keyword = request.GET.get('filter_keyword', '')
+    if filter_keyword:
+        filter = Q(lastname__icontains=filter_keyword) | Q(firstname__icontains=filter_keyword) | Q(email__icontains=filter_keyword)
+
+        filternode = ET.SubElement(pagenode, 'filter')
+        ET.SubElement(filternode, 'keyword').text = filter_keyword
+
+    filter_status = request.GET.get('filter_status', '')
+    if filter_status:
+        if filter_status == 'current':
+            q = Q(last_renewed_on__gte=datetime.date.today() - datetime.timedelta(days=700))
+        else:
+            q = Q(last_renewed_on__lte=datetime.date.today() - datetime.timedelta(days=700))
+
+        if filter:
+            filter = filter & q
+        else:
+            filter = q
+
+        if not filternode:
+            filternode = ET.SubElement(pagenode, 'filter')
+        ET.SubElement(filternode, 'status').text = filter_status
+
+    if filter:
+        queryset = models.Foundationmembers.objects.filter(filter)
+    else:
+        queryset = models.Foundationmembers.objects.all()
 
     page = setup_xml_paginator(request, pagenode, queryset)
     for member in page.object_list:

Modified: branches/django/www/list_foundationmembers.xsl
==============================================================================
--- branches/django/www/list_foundationmembers.xsl	(original)
+++ branches/django/www/list_foundationmembers.xsl	Fri Jun 27 20:40:05 2008
@@ -23,11 +23,17 @@
      <tr>
       <td>
       <form method="GET" action="{$script}" name="filterform">
-       Search: <input type="text" name="filter_name" value="{filter_name}" onchange="this.form.submit()"/>
-       <select name="filter_old" onchange="this.form.submit()">
-        <option value="all">All members</option>
-        <option value="current">Current members</option>
-        <option value="needrenewal">Old members needing renewal</option>
+       Search: <input type="text" name="filter_keyword" value="{filter/keyword}" onchange="this.form.submit()"/>
+       <select name="filter_status" onchange="this.form.submit()">
+        <option value=""><xsl:if test="filter/status = ''"><xsl:attribute name="checked">checked</xsl:attribute></xsl:if>
+          All members
+        </option>
+        <option value="current"><xsl:if test="filter/status = 'current'"><xsl:attribute name="checked">checked</xsl:attribute></xsl:if>
+          Current members
+        </option>
+        <option value="needrenewal"><xsl:if test="filter/status = 'needrenewal'"><xsl:attribute name="checked">checked</xsl:attribute></xsl:if>
+          Old members needing renewal
+        </option>
        </select>
        <noscript>
         <input type="submit" value="&gt; &gt;"/>
@@ -90,8 +96,8 @@
         	<xsl:if test="boolean(need_to_renew)">
 		  <form method="POST" action="{$script}" name="filterform" style="display: inline">
 		    <input type="hidden" name="mango_token" value="{/page/@token}"/>
-		    <input type="hidden" name="filter_name" value="{filter_name}"/>
-		    <input type="hidden" name="filter_old" value="{filter_old}"/>
+		    <input type="hidden" name="filter_name" value="{filter/keyword}"/>
+		    <input type="hidden" name="filter_status" value="{filter/status}"/>
 		    <input type="hidden" name="page" value="{page}"/>
 		    <input type="hidden" name="renew" value="{id}"/>
 		    <input type="submit" value="Renew"/>



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]