[Mpuls-commits] r3430 - in base/trunk: . mpulsweb/lib mpulsweb/templates/casemanagement

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Tue Aug 17 20:38:40 CEST 2010


Author: bh
Date: 2010-08-17 20:38:39 +0200 (Tue, 17 Aug 2010)
New Revision: 3430

Modified:
   base/trunk/ChangeLog
   base/trunk/mpulsweb/lib/search.py
   base/trunk/mpulsweb/templates/casemanagement/search.mako
Log:
Add basic support for search based on gender

* mpulsweb/lib/search.py (CaseSearch.get_gender_clause): New.
Handle the conditional clause for gender searches
(CaseSearch.get_where): Add gender clause.  The default
implementation simply returns 'TRUE' so derived classes will have
to provide the appropriate application specific logic.  The base
class cannot really handle it because the actual values to search
for are application dependend and not search based on gender
doesn't make sense in all applications.

* mpulsweb/templates/casemanagement/search.mako: Add options to
search by gender if the current application supports it.


Modified: base/trunk/ChangeLog
===================================================================
--- base/trunk/ChangeLog	2010-08-17 18:34:08 UTC (rev 3429)
+++ base/trunk/ChangeLog	2010-08-17 18:38:39 UTC (rev 3430)
@@ -1,5 +1,21 @@
 2010-08-17  Bernhard Herzog  <bh at intevation.de>
 
+	Add basic support for search based on gender
+
+	* mpulsweb/lib/search.py (CaseSearch.get_gender_clause): New.
+	Handle the conditional clause for gender searches
+	(CaseSearch.get_where): Add gender clause.  The default
+	implementation simply returns 'TRUE' so derived classes will have
+	to provide the appropriate application specific logic.  The base
+	class cannot really handle it because the actual values to search
+	for are application dependend and not search based on gender
+	doesn't make sense in all applications.
+
+	* mpulsweb/templates/casemanagement/search.mako: Add options to
+	search by gender if the current application supports it.
+
+2010-08-17  Bernhard Herzog  <bh at intevation.de>
+
 	* mpulsweb/lib/search.py (Search.supports_option): New.  To be
 	used by e.g. templates to determine which search options the
 	current application supports

Modified: base/trunk/mpulsweb/lib/search.py
===================================================================
--- base/trunk/mpulsweb/lib/search.py	2010-08-17 18:34:08 UTC (rev 3429)
+++ base/trunk/mpulsweb/lib/search.py	2010-08-17 18:38:39 UTC (rev 3430)
@@ -208,6 +208,15 @@
         return ("st.status IN (%s)"
                 % ",".join([str(x) for x in options["states"]]))
 
+    def get_gender_clause(self, options):
+        """Return the search condition to select cases based on gender.
+        The default implementation simply returns 'TRUE'.
+
+        Derived classes should override this method and include 'gender'
+        in their VALID_OPTIONS value.
+        """
+        return "TRUE"
+
     def get_where(self, search, options):
         allowed_viewer = self.get_allowed_viewer_clause(search, options)
         editor = self.get_editor_clause(search, options)
@@ -215,9 +224,10 @@
         needle_expr = self.get_needle_clause(search, options)
         time_interval = self.get_dates_clause(search, options)
         status_expr = self.get_status_clause(search, options)
+        gender = self.get_gender_clause(search, options)
 
         return " AND ".join((needle_expr, status_expr, allowed_viewer, editor,
-                             time_interval, phases))
+                             time_interval, phases, gender))
 
     def get_order(self, options):
         sort_field = options.get('sort_field', "m.id")

Modified: base/trunk/mpulsweb/templates/casemanagement/search.mako
===================================================================
--- base/trunk/mpulsweb/templates/casemanagement/search.mako	2010-08-17 18:34:08 UTC (rev 3429)
+++ base/trunk/mpulsweb/templates/casemanagement/search.mako	2010-08-17 18:38:39 UTC (rev 3430)
@@ -98,6 +98,22 @@
           <form:error name="edate">
         </td>
       </tr>
+      % if g.case_search.supports_option("gender"):
+        <tr style="${not c.extended_search and 'display:none' or ''}">
+          <td class="label">${_('Gender')}</td>
+          <td>
+            <select name="gender" id="gender">
+              <option value="-2">${_('All')}</option>
+              <option value="0">${_('Female')}</option>
+              <option value="1">${_('Male')}</option>
+              <option value="-1">${_('Unspecified')}</option>
+            </select>
+          </td>
+          <td>
+            <form:error name="gender">
+          </td>
+        </tr>
+      % endif
       <tr>
         <td class=""></td>
         <td></td>



More information about the Mpuls-commits mailing list