[Mpuls-commits] r3415 - in base/trunk: . mpulsweb/lib

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Tue Aug 17 11:01:58 CEST 2010


Author: bh
Date: 2010-08-17 11:01:57 +0200 (Tue, 17 Aug 2010)
New Revision: 3415

Modified:
   base/trunk/ChangeLog
   base/trunk/mpulsweb/lib/search.py
Log:
* mpulsweb/lib/search.py (CaseSearch.get_status_clause): New.
Build the conditional clause that selects cases based on the
status.
(CaseSearch.get_where): Use get_status_clause instead of building
part of that clause inline in get_where.
(SEARCH_WHERE): Adapt to new handling of he status clause


Modified: base/trunk/ChangeLog
===================================================================
--- base/trunk/ChangeLog	2010-08-16 15:56:47 UTC (rev 3414)
+++ base/trunk/ChangeLog	2010-08-17 09:01:57 UTC (rev 3415)
@@ -1,3 +1,12 @@
+2010-08-17  Bernhard Herzog  <bh at intevation.de>
+
+	* mpulsweb/lib/search.py (CaseSearch.get_status_clause): New.
+	Build the conditional clause that selects cases based on the
+	status.
+	(CaseSearch.get_where): Use get_status_clause instead of building
+	part of that clause inline in get_where.
+	(SEARCH_WHERE): Adapt to new handling of he status clause
+
 2010-08-16  Bernhard Herzog  <bh at intevation.de>
 
 	* mpulsweb/controllers/case_overview.py (get_sort): Refactor a

Modified: base/trunk/mpulsweb/lib/search.py
===================================================================
--- base/trunk/mpulsweb/lib/search.py	2010-08-16 15:56:47 UTC (rev 3414)
+++ base/trunk/mpulsweb/lib/search.py	2010-08-17 09:01:57 UTC (rev 3415)
@@ -32,11 +32,11 @@
 SEARCH_ORDER = """ORDER BY %s %s"""
 SEARCH_WHERE = """
       %s
-      AND st.status IN (%s)
       AND %s
       AND %s
       AND %s
       AND %s
+      AND %s
 """
 
 
@@ -208,6 +208,12 @@
             time_interval = "(%s)" % "OR".join(time_interval_str)
         return time_interval
 
+    def get_status_clause(self, options, allowed_states):
+        """Return the search condition to select cases based on status.
+        Derived classes may override this method if necessary.
+        """
+        return "st.status IN (%s)" % ",".join([str(x) for x in allowed_states])
+
     def get_where(self, search, options, allowed_states, bad_types, phaseslist,
                   fieldsdic):
         allowed_viewer = self.get_allowed_viewer_clause(options)
@@ -215,9 +221,9 @@
         phases = self.get_phases_clause(options, phaseslist)
         needle_expr = self.get_needle_clause(options, search)
         time_interval = self.get_dates_clause(options, phaseslist)
+        status_expr = self.get_status_clause(options, allowed_states)
 
-        return SEARCH_WHERE % (needle_expr,
-                               ",".join([str(x) for x in allowed_states]),
+        return SEARCH_WHERE % (needle_expr, status_expr,
                                allowed_viewer, editor,
                                time_interval, phases)
 



More information about the Mpuls-commits mailing list