[Mpuls-commits] r3420 - in jmd/trunk: . jmdstrukturweb/lib
scm-commit@wald.intevation.org
scm-commit at wald.intevation.org
Tue Aug 17 15:40:29 CEST 2010
Author: bh
Date: 2010-08-17 15:40:28 +0200 (Tue, 17 Aug 2010)
New Revision: 3420
Modified:
jmd/trunk/ChangeLog
jmd/trunk/jmdstrukturweb/lib/search.py
Log:
* jmdstrukturweb/lib/search.py (CaseSearch.get_where): Removed.
The implementation was an incorrect one from an old waska or wasko
code-base anyway and the base class method should be fine in
principle.
Modified: jmd/trunk/ChangeLog
===================================================================
--- jmd/trunk/ChangeLog 2010-08-17 13:39:07 UTC (rev 3419)
+++ jmd/trunk/ChangeLog 2010-08-17 13:40:28 UTC (rev 3420)
@@ -1,5 +1,12 @@
2010-08-17 Bernhard Herzog <bh at intevation.de>
+ * jmdstrukturweb/lib/search.py (CaseSearch.get_where): Removed.
+ The implementation was an incorrect one from an old waska or wasko
+ code-base anyway and the base class method should be fine in
+ principle.
+
+2010-08-17 Bernhard Herzog <bh at intevation.de>
+
* jmdstrukturweb/public/formed/formedtree.xml: Update to new
formed description with time flags on the date fields so that
searching for date-ranges will work.
Modified: jmd/trunk/jmdstrukturweb/lib/search.py
===================================================================
--- jmd/trunk/jmdstrukturweb/lib/search.py 2010-08-17 13:39:07 UTC (rev 3419)
+++ jmd/trunk/jmdstrukturweb/lib/search.py 2010-08-17 13:40:28 UTC (rev 3420)
@@ -54,139 +54,6 @@
class CaseSearch(CaseBaseSearch):
- def get_where(self, search, options, allowed_states, bad_types, phaseslist,
- fieldsdic):
- # Ansicht eigene Fallakten / Vertretung
- which_user = 0
- allowed_viewer = "FALSE"
- if options.has_key('own'):
- which_user += 2
- if options.has_key('standin'):
- which_user += 1
- if which_user == 1:
- allowed_viewer = "m.bearbeiter_id <> %s" % options.get('standin')
- if which_user == 2:
- allowed_viewer = "m.bearbeiter_id = %s" % options.get('own')
- if which_user == 3:
- allowed_viewer = "TRUE"
- allowed_viewer = "TRUE"
- allowed_viewer = (hasRole(['admin_ka', 'pb_ka'])
- and "TRUE" or allowed_viewer)
- # Bearbeiter
- editor = (options.has_key('editor')
- and "m.bearbeiter_id = %s" % options.get('editor') or "TRUE")
+ pass
- #Phases
- phases = 'TRUE' #default
- if phaseslist:
- phases = ('m.id in'
- ' (SELECT id from master_tbl_view WHERE phase in (%s))'
- % ','.join([str(p) for p in phaseslist]))
-
- fields = {'needle': ""}
- fields['needle'] = " ".join(search)
- log.debug("My match fields: %s" % self.match_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)))
-
- needle_expr = needle_expr % fields
- needle_expr = "TRUE"
- ee = "TRUE"
-
- #
- # WASKOSPECIFIC or at least depending on concrete naming of fields.
- #
-
- # Geschlecht
- gender = (options.get('gender')
- and "m.geschlecht = %s" % options.get('gender') or "TRUE")
-
- branch = (options.get('branch')
- and "b.filiale = '%s'" % options.get('branch') or "TRUE")
- fkz = (options.get('fkz')
- and "m.fkz = '%s'" % options.get('fkz') or "TRUE")
-
- #Identify bad cases
- bad_query = []
-
- INCONSISTENCY_TYPE_QUERY = {} # remove this
-
- for type_id in bad_types:
- query = INCONSISTENCY_TYPE_QUERY.get(str(type_id))
- if query:
- bad_query.append(query)
- if len(bad_query) > 0:
- bad = "(%s)" % " OR ".join(bad_query)
- else:
- bad = 'TRUE'
-
- # This is a convinience option to ignore older cases in the
- # inconsistency search
- if options.get('only_cases_after'):
- only_cases_after = ("coalesce(erstgespraech, now()) > '%s'"
- % options.get('only_cases_after'))
- else:
- only_cases_after = 'TRUE'
-
- #Build timeinterval
- time_interval = "TRUE"
- if (options.get('interval_start_date')
- and options.get('interval_end_date')):
- interval_start_field = options.get('interval_start_field',
- "erstgespraech")
- interval_end_field = options.get('interval_end_field',
- "datum_cm_ende")
- interval_start_date = options.get('interval_start_date',
- "1970-01-01")
- d = datetime.today()
- interval_end_date = options.get('interval_end_date',
- d.strftime('%Y-%m-%d'))
- fields = {'start_field': interval_start_field,
- 'start_date': interval_start_date,
- 'end_field': interval_end_field,
- 'end_date': interval_end_date}
- if interval_start_date != '1970-01-01':
- time_interval =("(coalesce(%(start_field)s, '1970-01-01'::date)"
- " <= '%(end_date)s'::date"
- " AND (coalesce(%(end_field)s, now())"
- " >= '%(start_date)s'::date))" % fields)
-
- #Migration
- migration = "TRUE"
- if options.get('migration'):
- if options.get('migration') == '1':
- migration = ("(nat_muspra not in (18, -1, -3)"
- " or nat_staat not in (1, -1, -3)"
- " or vater_land not in (29, -1, -3)"
- " or mutter_land not in (29, -1, -3))")
- elif options.get('migration') == '0':
- migration = ("(nat_muspra = 18 and nat_staat = 1"
- " and vater_land = 29 and mutter_land = 29)")
- elif options.get('migration') == '-1':
- migration = ("(not (nat_muspra not in (18,-1, -3)"
- " or nat_staat not in (1, -1,-3)"
- " or vater_land not in (29, -1, -3)"
- " or mutter_land not in (29, -1, -3))"
- " and not (nat_muspra = 18 and nat_staat = 1"
- " and vater_land = 29"
- " and mutter_land = 29))")
- elif options.get('migration') == '2':
- # FIXME: This case is WASKO specific. It used to search
- # cases that were incorrectly imported so that the
- # missing information can be corrected manually.
- # wasko/issue344
- migration = ("(nat_staat = 2"
- " and (vater_staat != 2 or mutter_staat != 2))")
-
- return SEARCH_WHERE % (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)
-
# vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8:
More information about the Mpuls-commits
mailing list