[Mpuls-commits] r135 - in waska/trunk: . waskaweb/controllers waskaweb/lib waskaweb/templates/casemanagement
scm-commit@wald.intevation.org
scm-commit at wald.intevation.org
Thu Sep 4 10:35:24 CEST 2008
Author: torsten
Date: 2008-09-04 10:35:22 +0200 (Thu, 04 Sep 2008)
New Revision: 135
Modified:
waska/trunk/ChangeLog.txt
waska/trunk/waskaweb/controllers/case_overview.py
waska/trunk/waskaweb/lib/evaluation.py
waska/trunk/waskaweb/lib/search.py
waska/trunk/waskaweb/lib/validators.py
waska/trunk/waskaweb/templates/casemanagement/agency_search.mako
waska/trunk/waskaweb/templates/casemanagement/search.mako
Log:
Search works now with new phase model
Modified: waska/trunk/ChangeLog.txt
===================================================================
--- waska/trunk/ChangeLog.txt 2008-09-04 06:05:45 UTC (rev 134)
+++ waska/trunk/ChangeLog.txt 2008-09-04 08:35:22 UTC (rev 135)
@@ -1,3 +1,22 @@
+2008-09-04 Torsten Irlaender <torsten.irlaender at intevation.de>
+
+ Search works now with new phase model
+
+ * waskaweb/controllers/case_overview.py,
+ waskaweb/lib/evaluation.py,
+ waskaweb/lib/search.py: Exchanged old
+ cm_state search with new phase search. cm-keyword is no longer
+ valid. Introduced phase-keywork instead. This was primarily needed as
+ precondition of the inconsistency checks on the blackboard, where we
+ need to differ between the different phases.
+ TODO: Currently the phases of waska are hardcoded in /lib/search
+ and /controllers/case_overview (parsing search options).
+ Ideally this can be done dynamically based on the phase model,
+ * waskaweb/lib/validators.py: Fixed default value of gender.
+ * waskaweb/templates/casemanagement/agency_search.mako,
+ waskaweb/templates/casemanagement/search.mako: Added new search
+ options for cm-phase "Keine Angabe" and "Clearing"
+
2008-09-04 Sascha L. Teichmann <sascha.teichmann at intevation.de>
* waskaweb/lib/helpers.py: Added function to print times in weeks
Modified: waska/trunk/waskaweb/controllers/case_overview.py
===================================================================
--- waska/trunk/waskaweb/controllers/case_overview.py 2008-09-04 06:05:45 UTC (rev 134)
+++ waska/trunk/waskaweb/controllers/case_overview.py 2008-09-04 08:35:22 UTC (rev 135)
@@ -137,9 +137,9 @@
if options.get('show_anonymized') == '1':
search_options.append('state:%s' % 5)
# For cm users show cases which are marked for anon too
- if h.hasRole('cm_ka'):
+ if h.hasRole('cm_ka'):
search_options.append('state:%s' % 4)
- if options.get('gender') >= -1:
+ if options.get('gender', '-2') != '-2':
search_options.append('gender:%s' % options.get('gender'))
if options.get('branch'):
search_options.append('branch:%s' % options.get('branch'))
@@ -148,17 +148,21 @@
#cm-states
cm_state = options.get('cm_state')
- cm = 'all' # default
- if cm_state:
- if cm_state == 1:
- cm = 'all'
- if cm_state == 2:
- cm = 'before'
- if cm_state == 3:
- cm = 'active'
- if cm_state == 4:
- cm = 'finished'
- search_options.append('cm:%s' % cm)
+ phases = [] # default
+ if cm_state:
+ if cm_state == 'none':
+ phases = []
+ if cm_state == 'clearing':
+ phases = [0,1]
+ if cm_state == 'before':
+ phases = [6,7]
+ if cm_state == 'active':
+ phases = [2]
+ if cm_state == 'finished':
+ phases = [3,4,5]
+ if cm_state == 'all':
+ phases = [-1,0,1,2,3,4,5,6,7]
+ search_options.append('%s' % ";".join("phase:%s" % p for p in phases))
#check build time_interval
year = options.get('year')
Modified: waska/trunk/waskaweb/lib/evaluation.py
===================================================================
--- waska/trunk/waskaweb/lib/evaluation.py 2008-09-04 06:05:45 UTC (rev 134)
+++ waska/trunk/waskaweb/lib/evaluation.py 2008-09-04 08:35:22 UTC (rev 135)
@@ -99,21 +99,15 @@
form_defaults = session.get('CASE_OVERVIEW_SEARCHOPTIONS') or {}
search_options = parseSearchOptions(form_defaults)
search_str = ";".join(search_options)
- search, options, states, bad_types = dummy_search._parse_search_str(search_str)
+ search, options, states, bad_types, phaseslist = dummy_search._parse_search_str(search_str)
gender = options.get('gender') and "m.geschlecht = %s" % options.get('gender') or "TRUE"
- #cm-state
- cm = 'TRUE' #default
- cm_state = options.get('cm', "all")
- if cm_state == 'clearing':
- cm = 'm.id in (SELECT id from master_tbl_eval_total_view WHERE phase in (0,1))'
- if cm_state == 'before':
- cm = 'm.id in (SELECT id from master_tbl_eval_total_view WHERE phase in (6,7))'
- if cm_state == 'active':
- cm = 'm.id in (SELECT id from master_tbl_eval_incm_view WHERE phase = 2)'
- if cm_state == 'finished':
- cm = 'm.id in (SELECT id from master_tbl_eval_incm_view WHERE phase IN (3,4,5))'
+ #Phases
+ phases = 'TRUE' #default
+ if phaseslist:
+ phases = 'm.id in (SELECT id from master_tbl_eval_total_view WHERE phase in (%s))' % ','.join([str(p) for p in phaseslist])
+
time_interval = "TRUE"
interval_start_field = options.get('interval_start_field', "erstgespraech")
interval_end_field = options.get('interval_end_field', "beendigung_5")
@@ -134,7 +128,7 @@
else:
valid_data = "TRUE"
- where = "AND ".join([fkz, '%s ' % gender, '%s ' % cm, '%s ' % time_interval, '%s ' % valid_data])
+ where = "AND ".join([fkz, '%s ' % gender, '%s ' % phases, '%s ' % time_interval, '%s ' % valid_data])
return where
def perform(self):
Modified: waska/trunk/waskaweb/lib/search.py
===================================================================
--- waska/trunk/waskaweb/lib/search.py 2008-09-04 06:05:45 UTC (rev 134)
+++ waska/trunk/waskaweb/lib/search.py 2008-09-04 08:35:22 UTC (rev 135)
@@ -37,7 +37,7 @@
SAVE_SEARCH = re.compile(r'[^\w:;\-\. ]', re.UNICODE)
-VALID_OPTIONS = ['editor', 'own', 'standin', 'state', 'sort_field', 'sort_order', 'interval_start_date', 'interval_end_date', 'interval_start_field', 'interval_end_field', 'gender', 'cm', 'branch', 'fkz', 'inconsistency', 'bad']
+VALID_OPTIONS = ['editor', 'own', 'standin', 'state', 'sort_field', 'sort_order', 'interval_start_date', 'interval_end_date', 'interval_start_field', 'interval_end_field', 'gender', 'phase', 'branch', 'fkz', 'inconsistency', 'bad']
SEARCH_CASE_SQL = \
""" SELECT
@@ -107,8 +107,9 @@
# implement some searchengine here
search = []
allowed_states = [-1]
- bad_types= []
- options = {}
+ bad_types = []
+ phases = []
+ options = {}
if s:
s = SAVE_SEARCH.sub(u'', s)
@@ -120,6 +121,8 @@
if key in VALID_OPTIONS:
if key == 'state':
allowed_states.append(int(value))
+ if key == 'phase':
+ phases.append(int(value))
if key in ['inconsistency', 'bad']:
bad_types.append(int(value))
else:
@@ -128,9 +131,9 @@
print >> sys.stderr, "Found invalid search syntax in options"
else:
search.append(option)
- return search, options, allowed_states, bad_types
+ return search, options, allowed_states, bad_types, phases
- def _build_sql(self, search, options, allowed_states, bad_types):
+ def _build_sql(self, search, options, allowed_states, bad_types, phases):
pass
def queryDB(self, sql, fields):
@@ -151,8 +154,8 @@
def perform(self, search_str):
'''Returns the result set of a search based on the search string'''
- search, options, states, bad_types = self._parse_search_str(search_str)
- sql, fields = self._build_sql(search, options, states, bad_types)
+ search, options, states, bad_types, phases = self._parse_search_str(search_str)
+ sql, fields = self._build_sql(search, options, states, bad_types, phases)
result = self.queryDB(sql, fields)
return result
@@ -160,21 +163,15 @@
def __init__(self):
Search.__init__(self)
- def _build_sql(self, search, options, allowed_states, bad_types):
+ def _build_sql(self, search, options, allowed_states, bad_types, phaseslist):
fields = {'needle': ""}
gender = options.get('gender') and "m.geschlecht = %s" % options.get('gender') or "TRUE"
- #cm-state
- cm = 'TRUE' #default
- cm_state = options.get('cm', "all")
- if cm_state == 'clearing':
- cm = 'm.id in (SELECT id from master_tbl_eval_total_view WHERE phase in (0,1))'
- if cm_state == 'before':
- cm = 'm.id in (SELECT id from master_tbl_eval_total_view WHERE phase in (6,7))'
- if cm_state == 'active':
- cm = 'm.id in (SELECT id from master_tbl_eval_incm_view WHERE phase = 2)'
- if cm_state == 'finished':
- cm = 'm.id in (SELECT id from master_tbl_eval_incm_view WHERE phase IN (3,4,5))'
+ #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])
+
time_interval = "TRUE"
interval_start_field = options.get('interval_start_field', "erstgespraech")
interval_end_field = options.get('interval_end_field', "beendigung_5")
@@ -192,14 +189,14 @@
sort_field = options.get('sort_field', "name_1")
sort_order = options.get('sort_order', "desc")
fields['needle'] = " ".join(search)
- SQL = SEARCH_AGENCY_SQL % (gender, time_interval, cm, sort_field, sort_order)
+ SQL = SEARCH_AGENCY_SQL % (gender, time_interval, phases, sort_field, sort_order)
return (SQL, fields)
class CaseSearch(Search):
def __init__(self):
Search.__init__(self)
- def _build_sql(self, search, options, allowed_states, bad_types):
+ def _build_sql(self, search, options, allowed_states, bad_types, phaseslist):
fields = {'needle': ""}
# Show all cases regardless if the privacy statement has been declined
#ee = h.hasRole(['cm_ka']) and "m.einverstaendniserklaerung <> 0" or "TRUE"
@@ -247,20 +244,13 @@
(coalesce(%(end_field)s, now()) >= '%(start_date)s'::date)) OR \
(st.zugriff >= '%(start_date)s'::date)))" % fields
- #cm-state
- cm = 'TRUE' #default
- cm_state = options.get('cm', "all")
- if cm_state == 'clearing':
- cm = 'm.id in (SELECT id from master_tbl_eval_total_view WHERE phase in (0,1))'
- if cm_state == 'before':
- cm = 'm.id in (SELECT id from master_tbl_eval_total_view WHERE phase in (6,7))'
- if cm_state == 'active':
- cm = 'm.id in (SELECT id from master_tbl_eval_incm_view WHERE phase = 2)'
- if cm_state == 'finished':
- cm = 'm.id in (SELECT id from master_tbl_eval_incm_view WHERE phase IN (3,4,5))'
+ #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'] = " ".join(search)
- SQL = SEARCH_CASE_SQL % (",".join([str(x) for x in allowed_states]), ee, allowed_viewer, editor, gender, time_interval, cm, branch, fkz, bad, sort_field, sort_order)
+ SQL = SEARCH_CASE_SQL % (",".join([str(x) for x in allowed_states]), ee, allowed_viewer, editor, gender, time_interval, phases, branch, fkz, bad, sort_field, sort_order)
return (SQL, fields)
# vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8:
Modified: waska/trunk/waskaweb/lib/validators.py
===================================================================
--- waska/trunk/waskaweb/lib/validators.py 2008-09-04 06:05:45 UTC (rev 134)
+++ waska/trunk/waskaweb/lib/validators.py 2008-09-04 08:35:22 UTC (rev 135)
@@ -263,7 +263,7 @@
max_speicherdauer = MaxMinInt(min=7, max=180, not_empty=True)
class SearchCaseForm(BaseFormValidator):
- gender = formencode.validators.Int(if_missing=None)
+ gender = formencode.validators.Int(if_missing='-2')
cm_state = formencode.validators.Int(if_missing=None)
class SearchAgencyForm(SearchCaseForm):
Modified: waska/trunk/waskaweb/templates/casemanagement/agency_search.mako
===================================================================
--- waska/trunk/waskaweb/templates/casemanagement/agency_search.mako 2008-09-04 06:05:45 UTC (rev 134)
+++ waska/trunk/waskaweb/templates/casemanagement/agency_search.mako 2008-09-04 08:35:22 UTC (rev 135)
@@ -20,10 +20,12 @@
<td width="80" valign="top"><label for="cm_state">CM-Status:</label></td>
<td valign="top">
<select name="cm_state" id="cm_state">
- <option value="1">Alle</option>
- <option value="2">Beratungskunde</option>
- <option value="3">CM-Kunde</option>
- <option value="4">CM-Abgeschlossen</option>
+ <option value="none">Keine Auswahl</option>
+ <option value="all">Alle</option>
+ <option value="clearing">Clearing</option>
+ <option value="before">Beratungskunde</option>
+ <option value="active">CM-Laufend</option>
+ <option value="finished">CM-Abgeschlossen</option>
</select>
</td>
</tr>
Modified: waska/trunk/waskaweb/templates/casemanagement/search.mako
===================================================================
--- waska/trunk/waskaweb/templates/casemanagement/search.mako 2008-09-04 06:05:45 UTC (rev 134)
+++ waska/trunk/waskaweb/templates/casemanagement/search.mako 2008-09-04 08:35:22 UTC (rev 135)
@@ -77,10 +77,12 @@
<td width="80" valign="top"><label for="cm_state">CM-Status:</label></td>
<td valign="top">
<select name="cm_state" id="cm_state">
- <option value="1">Alle</option>
- <option value="2">Beratungskunde</option>
- <option value="3">CM-Kunde</option>
- <option value="4">CM-Abgeschlossen</option>
+ <option value="none">Keine Auswahl</option>
+ <option value="all">Alle</option>
+ <option value="clearing">Clearing</option>
+ <option value="before">Beratungskunde</option>
+ <option value="active">CM-Laufend</option>
+ <option value="finished">CM-Abgeschlossen</option>
</select>
</td>
</tr>
More information about the Mpuls-commits
mailing list