[Mpuls-commits] r3410 - in base/trunk: . mpulsweb/lib
scm-commit@wald.intevation.org
scm-commit at wald.intevation.org
Fri Aug 13 20:37:35 CEST 2010
Author: bh
Date: 2010-08-13 20:37:34 +0200 (Fri, 13 Aug 2010)
New Revision: 3410
Modified:
base/trunk/ChangeLog
base/trunk/mpulsweb/lib/search.py
Log:
* mpulsweb/lib/search.py (CaseSearch.get_needle_clause): Refactor
to simplify the logic a little and generate a simple "TRUE" if no
search terms were given by the user.
Modified: base/trunk/ChangeLog
===================================================================
--- base/trunk/ChangeLog 2010-08-13 18:23:13 UTC (rev 3409)
+++ base/trunk/ChangeLog 2010-08-13 18:37:34 UTC (rev 3410)
@@ -1,5 +1,11 @@
2010-08-13 Bernhard Herzog <bh at intevation.de>
+ * mpulsweb/lib/search.py (CaseSearch.get_needle_clause): Refactor
+ to simplify the logic a little and generate a simple "TRUE" if no
+ search terms were given by the user.
+
+2010-08-13 Bernhard Herzog <bh at intevation.de>
+
* mpulsweb/lib/search.py (CaseSearch.get_editor_clause): Refactor
to make the logic clearer
Modified: base/trunk/mpulsweb/lib/search.py
===================================================================
--- base/trunk/mpulsweb/lib/search.py 2010-08-13 18:23:13 UTC (rev 3409)
+++ base/trunk/mpulsweb/lib/search.py 2010-08-13 18:37:34 UTC (rev 3410)
@@ -177,17 +177,16 @@
"""Return the search condition to select cases based on search terms.
Derived classes may override this method if necessary.
"""
- fields = {'needle': ""}
- fields['needle'] = " ".join(search)
- needle_expr = ("((%s) OR (%s))"
- % (" OR ".join("m.%s ~* '%%(needle)s'"
- % field
- for field in self.match_fields),
- " AND ".join("m.%s IS NULL"
- % field
- for field in self.match_fields)))
- needle_expr = needle_expr % fields
- return needle_expr
+ if search:
+ needle_expr = ("((%s) OR (%s))"
+ % (" OR ".join("m.%s ~* '%%(needle)s'"
+ % field
+ for field in self.match_fields),
+ " AND ".join("m.%s IS NULL"
+ % field
+ for field in self.match_fields)))
+ return needle_expr % dict(needle=" ".join(search))
+ return "TRUE"
def get_dates_clause(self, options, phaseslist):
"""Return the search condition to select cases based on start/end dates.
More information about the Mpuls-commits
mailing list