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

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Fri Aug 27 19:41:03 CEST 2010


Author: bh
Date: 2010-08-27 19:41:02 +0200 (Fri, 27 Aug 2010)
New Revision: 3470

Modified:
   base/trunk/ChangeLog
   base/trunk/mpulsweb/lib/search.py
Log:
* mpulsweb/lib/search.py (Search.convert_form_parameters)
(CaseSearch.convert_form_parameters): Move the method from Search
to CaseSearch.  The parameters it handles only make sense for
CaseSearch


Modified: base/trunk/ChangeLog
===================================================================
--- base/trunk/ChangeLog	2010-08-27 14:57:24 UTC (rev 3469)
+++ base/trunk/ChangeLog	2010-08-27 17:41:02 UTC (rev 3470)
@@ -1,5 +1,12 @@
 2010-08-27  Bernhard Herzog  <bh at intevation.de>
 
+	* mpulsweb/lib/search.py (Search.convert_form_parameters)
+	(CaseSearch.convert_form_parameters): Move the method from Search
+	to CaseSearch.  The parameters it handles only make sense for
+	CaseSearch
+
+2010-08-27  Bernhard Herzog  <bh at intevation.de>
+
 	* mpulsweb/lib/validators.py (SearchCaseForm.cm_state): Removed.
 	Not used anymore.
 

Modified: base/trunk/mpulsweb/lib/search.py
===================================================================
--- base/trunk/mpulsweb/lib/search.py	2010-08-27 14:57:24 UTC (rev 3469)
+++ base/trunk/mpulsweb/lib/search.py	2010-08-27 17:41:02 UTC (rev 3470)
@@ -45,62 +45,6 @@
     def supports_option(self, option):
         return option in self.VALID_OPTIONS
 
-    def convert_form_parameters(self, options, user):
-        """Convert form parameters to search options.
-        The parameter user is the user object for the current user.
-        """
-        search_options = []
-
-        # Searchstring
-        if options.get('search_str'):
-            search_options.append(options.get('search_str'))
-
-        # Status
-        if options.has_key('state'):
-            for s in options['state']:
-                search_options.append('state:%s' % s)
-
-        # Responsibilty
-        # shown cases where the user is editor, or standin or both
-        if options.get('own'):
-            search_options.append('own:%s' % user.id)
-        if options.get('standin'):
-            search_options.append('standin:%s' % user.id)
-
-        # Editor
-        # shown cases where the user is editor or all (-1)
-        if options.get('editor') and options.get('editor') != -1:
-            search_options.append('editor:%s' % options.get('editor'))
-
-        # Phase
-        if options.has_key('phase'):
-            for pp in options['phase']:
-                # Get phasepart ids for the selected phasepairs. Only if
-                # pairs are defined.
-                pairs = g.mpuls_config.get('phases', 'pairs')
-                if len(pairs) <= 0:
-                    continue
-                for p in pairs[0].get(str(pp), [-1]):
-                    search_options.append('phase:%s' % p)
-        # Dates
-        if (options.has_key('sdate')
-            and options.has_key('edate')
-            and options.get('sdate') is not None
-            and options.get('edate') is not None):
-            search_options.append('sdate:%s' % options.get('sdate'))
-            search_options.append('edate:%s' % options.get('edate'))
-
-        # gender
-        if options.get("gender", -2) != -2:
-            search_options.append("gender:%s" % options["gender"])
-
-        # branch office
-        if options.get("branch"):
-            search_options.append("branch:%s" % options["branch"])
-
-        return search_options
-
-
     def _parse_search_str(self, s):
         # TODO This is a very very simple approach. We should defentiley
         # implement some searchengine here
@@ -173,6 +117,61 @@
             retrieve = "%s," % retrieve
         return self.SEARCH_FIELDS % retrieve
 
+    def convert_form_parameters(self, options, user):
+        """Convert form parameters to search options.
+        The parameter user is the user object for the current user.
+        """
+        search_options = []
+
+        # Searchstring
+        if options.get('search_str'):
+            search_options.append(options.get('search_str'))
+
+        # Status
+        if options.has_key('state'):
+            for s in options['state']:
+                search_options.append('state:%s' % s)
+
+        # Responsibilty
+        # shown cases where the user is editor, or standin or both
+        if options.get('own'):
+            search_options.append('own:%s' % user.id)
+        if options.get('standin'):
+            search_options.append('standin:%s' % user.id)
+
+        # Editor
+        # shown cases where the user is editor or all (-1)
+        if options.get('editor') and options.get('editor') != -1:
+            search_options.append('editor:%s' % options.get('editor'))
+
+        # Phase
+        if options.has_key('phase'):
+            for pp in options['phase']:
+                # Get phasepart ids for the selected phasepairs. Only if
+                # pairs are defined.
+                pairs = g.mpuls_config.get('phases', 'pairs')
+                if len(pairs) <= 0:
+                    continue
+                for p in pairs[0].get(str(pp), [-1]):
+                    search_options.append('phase:%s' % p)
+        # Dates
+        if (options.has_key('sdate')
+            and options.has_key('edate')
+            and options.get('sdate') is not None
+            and options.get('edate') is not None):
+            search_options.append('sdate:%s' % options.get('sdate'))
+            search_options.append('edate:%s' % options.get('edate'))
+
+        # gender
+        if options.get("gender", -2) != -2:
+            search_options.append("gender:%s" % options["gender"])
+
+        # branch office
+        if options.get("branch"):
+            search_options.append("branch:%s" % options["branch"])
+
+        return search_options
+
     def get_allowed_viewer_clause(self, search, options):
         """Return the search condition that selects based on owner or standin.
         This means the search condition a case manager user can use to



More information about the Mpuls-commits mailing list