[Mpuls-commits] r1526 - in wasko/branches/2.0: . waskaweb/lib waskaweb/model
scm-commit@wald.intevation.org
scm-commit at wald.intevation.org
Thu Feb 11 20:23:18 CET 2010
Author: bh
Date: 2010-02-11 20:23:14 +0100 (Thu, 11 Feb 2010)
New Revision: 1526
Modified:
wasko/branches/2.0/ChangeLog
wasko/branches/2.0/waskaweb/lib/search.py
wasko/branches/2.0/waskaweb/model/case.py
Log:
* waskaweb/lib/search.py (SEARCH_CASE_SQL): Make the list of the
fields to retrieve and the match expression for the needle more
dynamic.
(CaseSearch.__init__): New parameter retrieve_fields and
match_fields for the list of fields to retrieve and the list of
fields to match
(CaseSearch._build_sql): Build the sql-fragments for the list of
fields to retrieve and the match expression for the needs from the
list of fields to match and insert them into the SQL statement.
* waskaweb/model/case.py (CaseOverview.search): Use
Case.get_search_retrieve_fields() and
Case.get_search_match_fields() to pass the field names to the
CaseSearch.
Modified: wasko/branches/2.0/ChangeLog
===================================================================
--- wasko/branches/2.0/ChangeLog 2010-02-11 19:16:12 UTC (rev 1525)
+++ wasko/branches/2.0/ChangeLog 2010-02-11 19:23:14 UTC (rev 1526)
@@ -1,5 +1,22 @@
2010-02-11 Bernhard Herzog <bh at intevation.de>
+ * waskaweb/lib/search.py (SEARCH_CASE_SQL): Make the list of the
+ fields to retrieve and the match expression for the needle more
+ dynamic.
+ (CaseSearch.__init__): New parameter retrieve_fields and
+ match_fields for the list of fields to retrieve and the list of
+ fields to match
+ (CaseSearch._build_sql): Build the sql-fragments for the list of
+ fields to retrieve and the match expression for the needs from the
+ list of fields to match and insert them into the SQL statement.
+
+ * waskaweb/model/case.py (CaseOverview.search): Use
+ Case.get_search_retrieve_fields() and
+ Case.get_search_match_fields() to pass the field names to the
+ CaseSearch.
+
+2010-02-11 Bernhard Herzog <bh at intevation.de>
+
* waskaweb/model/case.py (Case.fields): Set search_retrieve and
search_match on the appropriate fields.
Modified: wasko/branches/2.0/waskaweb/lib/search.py
===================================================================
--- wasko/branches/2.0/waskaweb/lib/search.py 2010-02-11 19:16:12 UTC (rev 1525)
+++ wasko/branches/2.0/waskaweb/lib/search.py 2010-02-11 19:23:14 UTC (rev 1526)
@@ -48,10 +48,7 @@
SEARCH_CASE_SQL = \
""" SELECT
m.id,
- m.name,
- m.vorname,
- m.fn,
- m.bearbeiter_id,
+ %s,
st.status,
st.zugriff,
st.id as s_id
@@ -61,13 +58,7 @@
JOIN ka_benutzer_tbl b ON
m.bearbeiter_id = b.id
WHERE
- ((m.vorname ~* %%(needle)s
- OR m.name ~* %%(needle)s
- OR m.fn ~* %%(needle)s)
- OR ( m.vorname IS NULL
- AND m.name IS NULL
- AND m.fn IS NULL
- ))
+ %s
AND st.status IN (%s)
AND %s
AND %s
@@ -154,8 +145,10 @@
class CaseSearch(Search):
- def __init__(self):
+ def __init__(self, retrieve_fields, match_fields):
Search.__init__(self)
+ self.retrieve_fields = retrieve_fields
+ self.match_fields = match_fields
def _build_sql(self, search, options, allowed_states, bad_types, phaseslist,
fieldsdic):
@@ -267,7 +260,17 @@
" and (vater_staat != 2 or mutter_staat != 2))")
fields['needle'] = " ".join(search)
- SQL = SEARCH_CASE_SQL % (",".join([str(x) for x in allowed_states]),
+
+ retrieve = ", ".join("m." + field for field in self.retrieve_fields)
+ 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)))
+ SQL = SEARCH_CASE_SQL % (retrieve, needle_expr,
+ ",".join([str(x) for x in allowed_states]),
ee, allowed_viewer, editor, gender,
time_interval, phases, branch, fkz, bad,
only_cases_after, migration, sort_field,
Modified: wasko/branches/2.0/waskaweb/model/case.py
===================================================================
--- wasko/branches/2.0/waskaweb/model/case.py 2010-02-11 19:16:12 UTC (rev 1525)
+++ wasko/branches/2.0/waskaweb/model/case.py 2010-02-11 19:23:14 UTC (rev 1526)
@@ -342,7 +342,8 @@
def search(self, search_str=None):
self.ds_list = []
- search = CaseSearch()
+ search = CaseSearch(Case.get_search_retrieve_fields(),
+ Case.get_search_match_fields())
result = search.perform(search_str)
factory = CaseFactory()
for row in result:
More information about the Mpuls-commits
mailing list