[Mpuls-commits] r117 - in waska/trunk: . waskaweb/controllers waskaweb/lib waskaweb/templates/casemanagement

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Tue Sep 2 17:11:11 CEST 2008


Author: torsten
Date: 2008-09-02 17:11:11 +0200 (Tue, 02 Sep 2008)
New Revision: 117

Modified:
   waska/trunk/ChangeLog.txt
   waska/trunk/waskaweb/controllers/case_overview.py
   waska/trunk/waskaweb/lib/search.py
   waska/trunk/waskaweb/templates/casemanagement/listbadcases.mako
Log:
Added new check for inconsistent cases


Modified: waska/trunk/ChangeLog.txt
===================================================================
--- waska/trunk/ChangeLog.txt	2008-09-02 13:56:40 UTC (rev 116)
+++ waska/trunk/ChangeLog.txt	2008-09-02 15:11:11 UTC (rev 117)
@@ -31,6 +31,16 @@
 
 	* waskaweb/public/images/icons/needed_12x12.png: Changed icon
 
+	Added new check for inconsistent cases.
+
+	* waskaweb/controllers/case_overview.py,
+	  waskaweb/lib/search.py,
+	  waskaweb/templates/casemanagement/listbadcases.mako: Check if the
+	  phase for the case is -1 (unknown). This is mainly usefull after
+	  upgrading the database to set the inital phase. If we can not
+	  determine for surein which phase this case belongs, the the unknown
+	  phase is set and the user needs to get active.
+
 2008-09-02  Sascha L. Teichmann <sascha.teichmann at intevation.de>
 
 	* waskaweb/lib/exportselection.py: New. out-factorized selection of case parts.

Modified: waska/trunk/waskaweb/controllers/case_overview.py
===================================================================
--- waska/trunk/waskaweb/controllers/case_overview.py	2008-09-02 13:56:40 UTC (rev 116)
+++ waska/trunk/waskaweb/controllers/case_overview.py	2008-09-02 15:11:11 UTC (rev 117)
@@ -296,12 +296,13 @@
     @checkRole(('admin_ka', 'cm_ka', 'pt_dlr'))
     def listBadCases(self):
         user = session.get('USER_AUTHORIZED')
-        c.type_1_list = CaseOverview().search('state:1;state:2;state:3;state:4;state:5;own:%s;bad:1' % user.id)
-        c.type_2_list = CaseOverview().search('state:1;state:2;state:3;state:4;state:5;own:%s;bad:2' % user.id)
-        c.type_3_list = CaseOverview().search('state:1;state:2;state:3;state:4;state:5;own:%s;bad:3' % user.id)
-        c.type_4_list = CaseOverview().search('state:1;state:2;state:3;state:4;state:5;own:%s;bad:4' % user.id)
-        c.type_5_list = CaseOverview().search('state:1;state:2;state:3;state:4;state:5;own:%s;bad:5' % user.id)
-        c.type_6_list = CaseOverview().search('state:1;state:2;state:3;state:4;state:5;own:%s;bad:6' % user.id)
+        c.type_1_list = CaseOverview().search('state:1;state:2;state:4;state:5;own:%s;inconsistency:1' % user.id)
+        c.type_2_list = CaseOverview().search('state:1;state:2;state:4;state:5;own:%s;inconsistency:2' % user.id)
+        c.type_3_list = CaseOverview().search('state:1;state:2;state:4;state:5;own:%s;inconsistency:3' % user.id)
+        c.type_4_list = CaseOverview().search('state:1;state:2;state:4;state:5;own:%s;inconsistency:4' % user.id)
+        c.type_5_list = CaseOverview().search('state:1;state:2;state:4;state:5;own:%s;inconsistency:5' % user.id)
+        c.type_6_list = CaseOverview().search('state:1;state:2;state:4;state:5;own:%s;inconsistency:6' % user.id)
+        c.type_7_list = CaseOverview().search('state:1;state:2;state:4;state:5;own:%s;inconsistency:7' % user.id)
         return render('/casemanagement/listbadcases.mako')
 
     @checkRole(('admin_ka', 'cm_ka', 'pt_dlr'))

Modified: waska/trunk/waskaweb/lib/search.py
===================================================================
--- waska/trunk/waskaweb/lib/search.py	2008-09-02 13:56:40 UTC (rev 116)
+++ waska/trunk/waskaweb/lib/search.py	2008-09-02 15:11:11 UTC (rev 117)
@@ -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', 'bad']
+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']
 
 SEARCH_CASE_SQL = \
 """ SELECT
@@ -77,12 +77,13 @@
       AND %s
     ORDER BY %s %s"""
 
-BAD_TYPE_QUERY = {'1': 'm.erstgespraech is NULL', 
+INCONSISTENCY_TYPE_QUERY = {'1': 'm.erstgespraech is NULL', 
                   '2': 'm.erstgespraech::timestamp > now()',
                   '3': 'm.erstgespraech::timestamp > m.beendigung_5::timestamp',
                   '4': 'm.beendigung_5::timestamp > now()',
                   '5': '(m.art_beendigung <> -1 AND m.beendigung_5 is NULL)',
-                  '6': '(m.art_beendigung = -1 AND m.beendigung_5 is not NULL)'}
+                  '6': '(m.art_beendigung = -1 AND m.beendigung_5 is not NULL)',
+                  '7': '(m.phase = -1)'}
 
 SEARCH_AGENCY_SQL = \
 """select count(m.id) as anzahl,
@@ -119,7 +120,7 @@
                         if key in VALID_OPTIONS:
                             if key == 'state':
                                 allowed_states.append(int(value))
-                            if key == 'bad':
+                            if key in ['inconsistency', 'bad']:
                                 bad_types.append(int(value))
                             else:
                                 options[key] = value
@@ -168,9 +169,9 @@
         if cm_state == 'before':
             cm = 'm.id not in (SELECT id from master_tbl_eval_incm_view)'
         if cm_state == 'active':
-            cm = 'm.id in (SELECT id from master_tbl_eval_incm_view WHERE art_beendigung = -1)'
+            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 art_beendigung <> -1)'
+            cm = 'm.id in (SELECT id from master_tbl_eval_incm_view WHERE phase IN (3,4,5))'
 
         time_interval = "TRUE"
         interval_start_field = options.get('interval_start_field', "erstgespraech")
@@ -220,7 +221,7 @@
         #Identify bad cases
         bad_query = []
         for type_id in bad_types:
-            query = BAD_TYPE_QUERY.get(str(type_id))
+            query = INCONSISTENCY_TYPE_QUERY.get(str(type_id))
             if query:
                 bad_query.append(query)
         if len(bad_query) > 0:
@@ -248,13 +249,12 @@
         cm = 'TRUE' #default
         cm_state = options.get('cm', "all")
         if cm_state == 'before':
-            cm = 'm.id not in (SELECT id from master_tbl_incm_view)'
+            cm = 'm.id not in (SELECT id from master_tbl_eval_incm_view)'
         if cm_state == 'active':
-            cm = 'm.id in (SELECT id from master_tbl_incm_view WHERE art_beendigung = -1)'
+            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_incm_view WHERE art_beendigung <> -1)'
+            cm = 'm.id in (SELECT id from master_tbl_eval_incm_view WHERE phase IN (3,4,5))'
 
-
         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) 
         return (SQL, fields)

Modified: waska/trunk/waskaweb/templates/casemanagement/listbadcases.mako
===================================================================
--- waska/trunk/waskaweb/templates/casemanagement/listbadcases.mako	2008-09-02 13:56:40 UTC (rev 116)
+++ waska/trunk/waskaweb/templates/casemanagement/listbadcases.mako	2008-09-02 15:11:11 UTC (rev 117)
@@ -11,7 +11,7 @@
   <input type="hidden" name="show_anonymized" value="1">
   <input type="hidden" name="show_own" value="1">
   <input type="hidden" name="show_open" value="1">
-  <input type="hidden" name="search_str" value="bad:1">
+  <input type="hidden" name="search_str" value="inconsistency:1">
   <input type="submit" value="Anzeigen"> (${len(c.type_1_list)} Fallakte(n))
   </form>
 </div>
@@ -23,7 +23,7 @@
   <input type="hidden" name="show_anonymized" value="1">
   <input type="hidden" name="show_own" value="1">
   <input type="hidden" name="show_open" value="1">
-  <input type="hidden" name="search_str" value="bad:2">
+  <input type="hidden" name="search_str" value="inconsistency:2">
   <input type="submit" value="Anzeigen"> (${len(c.type_2_list)} Fallakte(n))
   </form>
 </div>
@@ -35,7 +35,7 @@
   <input type="hidden" name="show_anonymized" value="1">
   <input type="hidden" name="show_own" value="1">
   <input type="hidden" name="show_open" value="1">
-  <input type="hidden" name="search_str" value="bad:3">
+  <input type="hidden" name="search_str" value="inconsistency:3">
   <input type="submit" value="Anzeigen"> (${len(c.type_3_list)} Fallakte(n))
   </form>
 </div>
@@ -47,7 +47,7 @@
   <input type="hidden" name="show_anonymized" value="1">
   <input type="hidden" name="show_own" value="1">
   <input type="hidden" name="show_open" value="1">
-  <input type="hidden" name="search_str" value="bad:4">
+  <input type="hidden" name="search_str" value="inconsistency:4">
   <input type="submit" value="Anzeigen"> (${len(c.type_4_list)} Fallakte(n))
   </form>
 </div>
@@ -59,7 +59,7 @@
   <input type="hidden" name="show_anonymized" value="1">
   <input type="hidden" name="show_own" value="1">
   <input type="hidden" name="show_open" value="1">
-  <input type="hidden" name="search_str" value="bad:5">
+  <input type="hidden" name="search_str" value="inconsistency:5">
   <input type="submit" value="Anzeigen"> (${len(c.type_5_list)} Fallakte(n))
   </form>
 </div>
@@ -71,8 +71,20 @@
   <input type="hidden" name="show_anonymized" value="1">
   <input type="hidden" name="show_own" value="1">
   <input type="hidden" name="show_open" value="1">
-  <input type="hidden" name="search_str" value="bad:6">
+  <input type="hidden" name="search_str" value="inconsistency:6">
   <input type="submit" value="Anzeigen"> (${len(c.type_6_list)} Fallakte(n))
   </form>
 </div>
 %endif
+%if len(c.type_7_list):
+<div>
+  <h2>Die aktuelle Phase der Fallakte konnte aufgrund von fehlenden Angaben nicht festgestellt werden</h2>
+  <form name="list1" action="${h.url_for(controller="case_overview", action="search")}" method=post>
+  <input type="hidden" name="show_anonymized" value="1">
+  <input type="hidden" name="show_own" value="1">
+  <input type="hidden" name="show_open" value="1">
+  <input type="hidden" name="search_str" value="inconsistency:7">
+  <input type="submit" value="Anzeigen"> (${len(c.type_7_list)} Fallakte(n))
+  </form>
+</div>
+%endif



More information about the Mpuls-commits mailing list