[Mpuls-commits] r152 - in waska/trunk: formed waskaweb/controllers waskaweb/lib waskaweb/templates/casemanagement

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Fri Sep 12 12:10:27 CEST 2008


Author: torsten
Date: 2008-09-12 12:10:27 +0200 (Fri, 12 Sep 2008)
New Revision: 152

Modified:
   waska/trunk/formed/annotations.xhtml
   waska/trunk/waskaweb/controllers/waska.py
   waska/trunk/waskaweb/lib/search.py
   waska/trunk/waskaweb/templates/casemanagement/listbadcases.mako
Log:
Added new search option to search for cases after a current date


Modified: waska/trunk/formed/annotations.xhtml
===================================================================
--- waska/trunk/formed/annotations.xhtml	2008-09-12 10:03:47 UTC (rev 151)
+++ waska/trunk/formed/annotations.xhtml	2008-09-12 10:10:27 UTC (rev 152)
@@ -14,7 +14,7 @@
 		zu gewährleisten, muss dieses Feld ausgefüllt werden.
 	</div>
         <div
-	id="beratung_ende:required:geburtsdatum,arbeitslosigkeit_1,geschlecht,dauer_nach_letzter_beschaeftigung,bezug_alg2,bezug_alg1,erwerbstaetigkeit_job,muttersprache,vater,mutter,geburtsland,schulabschluss_1,abschluss_ausserbetriebliche_ausbildung,abschluss_betriebliche_ausbildung,beieintrittistderjugendlichemehrfachantwortenmoeglich,datum_feststellung,datum_ende_beratung">
+	id="beratung_ende:required:geburtsdatum,arbeitslosigkeit_1,geschlecht,dauer_nach_letzter_beschaeftigung,bezug_alg2,bezug_alg1,erwerbstaetigkeit_job,muttersprache,vater,mutter,staatsangehoerigkeit,schulabschluss_1,abschluss_ausserbetriebliche_ausbildung,abschluss_betriebliche_ausbildung,beieintrittistderjugendlichemehrfachantwortenmoeglich,datum_feststellung,datum_ende_beratung">
 		<h2>Pflichtfelder für den Abschluss der Beratungstätigkeit</h2>
 		Um die Vollständigkeit der ESF-Stammdaten, sowie
 		definierte Start und Endpunkte der Beratungsphase
@@ -90,7 +90,7 @@
 		auszufüllen.
 	</div>
         <div
-	id="hilfe_auswertung:evaluation:geburtsland,muttersprache,vater,mutter,">
+	id="hilfe_auswertung:evaluation:staatsangehoerigkeit,muttersprache,vater,mutter,">
 		<h2>Migrationshintergrund</h2>
 		Dieses Feld wird in der oben genannten Auswertung ausgelesen.
 		Um möglichst aussagekräftige Ergebnisse in der internen

Modified: waska/trunk/waskaweb/controllers/waska.py
===================================================================
--- waska/trunk/waskaweb/controllers/waska.py	2008-09-12 10:03:47 UTC (rev 151)
+++ waska/trunk/waskaweb/controllers/waska.py	2008-09-12 10:10:27 UTC (rev 152)
@@ -91,7 +91,7 @@
         search_str1 = "state:1;state:2;state:4;state:5;bad:1;bad:2;bad:3;bad:4;bad:5;bad:6;bad:clearing_start;bad:clearing_ende;bad:beratung_start;bad:beratung_ende;bad:cm_start;bad:cm_ende;bad:nachbetreuung_start;bad:nachbetreuung_ende;own:%s" % user.id
 
         #Search inconsistencys on phases but ignore older cases. 
-        search_str2 = "state:1;state:2;state:4;bad:clearing_start;bad:clearing_ende;bad:beratung_start;bad:beratung_ende;bad:cm_start;bad:cm_ende;bad:nachbetreuung_start;bad:nachbetreuung_ende;interval_start_date:'2008-09-01';interval_end_date:'2011-09-01';own:%s" % user.id
+        search_str2 = "state:1;state:2;state:4;bad:clearing_start;bad:clearing_ende;bad:beratung_start;bad:beratung_ende;bad:cm_start;bad:cm_ende;bad:nachbetreuung_start;bad:nachbetreuung_ende;only_cases_after:'2008-09-01';own:%s" % user.id
 
         num_error_cases1 = len(CaseOverview().search(search_str1))
         num_error_cases2 = len(CaseOverview().search(search_str2))

Modified: waska/trunk/waskaweb/lib/search.py
===================================================================
--- waska/trunk/waskaweb/lib/search.py	2008-09-12 10:03:47 UTC (rev 151)
+++ waska/trunk/waskaweb/lib/search.py	2008-09-12 10:10:27 UTC (rev 152)
@@ -39,7 +39,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', 'phase', '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', 'only_cases_after', 'bad', 'field']
 
 SEARCH_CASE_SQL = \
 """ SELECT
@@ -77,6 +77,7 @@
       AND %s
       AND %s
       AND %s
+      AND %s
     ORDER BY %s %s"""
 
 INCONSISTENCY_LOCK = None
@@ -125,6 +126,7 @@
         allowed_states = [-1]
         bad_types      = []
         phases         = []
+        fields         = {}
         options        = {}
 
         if s:
@@ -139,17 +141,21 @@
                                 allowed_states.append(int(value))
                             if key == 'phase':
                                 phases.append(int(value))
+                            #if key == 'field':
+                            #    field, operator, fvalue = [x.strip() for x in value.split(" ")]
+                            #    fields[field] = fvalue
                             if key in ['inconsistency', 'bad']:
+                                print key, " ", value 
                                 bad_types.append(value)
                             else:
                                 options[key] = value
-                    except ValueError:
-                        print >> sys.stderr, "Found invalid search syntax in options"
+                    except ValueError, err :
+                        print >> sys.stderr, "Found invalid search syntax in options: %s" % err
                 else:
                     search.append(option)
-        return search, options, allowed_states, bad_types, phases
+        return search, options, allowed_states, bad_types, phases, fields
 
-    def _build_sql(self, search, options, allowed_states, bad_types, phases):
+    def _build_sql(self, search, options, allowed_states, bad_types, phases, fieldsdic):
         pass
 
     def queryDB(self, sql, fields):
@@ -170,8 +176,8 @@
 
     def perform(self, search_str):
         '''Returns the result set of a search based on the search string'''
-        search, options, states, bad_types, phases = self._parse_search_str(search_str)
-        sql, fields = self._build_sql(search, options, states, bad_types, phases)
+        search, options, states, bad_types, phases, fields = self._parse_search_str(search_str)
+        sql, fields = self._build_sql(search, options, states, bad_types, phases, fields)
         result = self.queryDB(sql, fields)
         return result
 
@@ -179,7 +185,7 @@
     def __init__(self):
         Search.__init__(self)
 
-    def _build_sql(self, search, options, allowed_states, bad_types, phaseslist):
+    def _build_sql(self, search, options, allowed_states, bad_types, phaseslist, fieldsdic):
         fields = {'needle': ""}
         gender = options.get('gender') and "m.geschlecht = %s" % options.get('gender') or "TRUE"
 
@@ -212,7 +218,7 @@
     def __init__(self):
         Search.__init__(self)
 
-    def _build_sql(self, search, options, allowed_states, bad_types, phaseslist):
+    def _build_sql(self, search, options, allowed_states, bad_types, phaseslist, fieldsdic):
         fields = {'needle': ""}
         # Show all cases regardless if the privacy statement has been declined
         #ee =  h.hasRole(['cm_ka']) and "m.einverstaendniserklaerung <> 0" or "TRUE"
@@ -258,6 +264,13 @@
         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'):
@@ -279,8 +292,18 @@
         if phaseslist:
             phases = 'm.id in (SELECT id from master_tbl_view WHERE phase in (%s))' % ','.join([str(p) for p in phaseslist])
 
+        ##User defined fieldsearch
+        #fieldsearchlist = [] 
+        #for field, value in fieldsdic.iteritems():
+        #    fieldsearchlist.append("%s = '%s'" % field, value)
+    
+        #if fieldsearchlist:
+        #    fieldsearch = "(%s)" % " AND ".join(fieldsearchlist)
+        #else:
+        #    fieldsearch = 'TRUE'
+
         fields['needle'] = " ".join(search) 
-        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) 
+        SQL = SEARCH_CASE_SQL % (",".join([str(x) for x in allowed_states]), ee, allowed_viewer, editor, gender, time_interval, phases, branch, fkz, bad, only_cases_after, sort_field, sort_order) 
         return (SQL, fields)
 
 # vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8:

Modified: waska/trunk/waskaweb/templates/casemanagement/listbadcases.mako
===================================================================
--- waska/trunk/waskaweb/templates/casemanagement/listbadcases.mako	2008-09-12 10:03:47 UTC (rev 151)
+++ waska/trunk/waskaweb/templates/casemanagement/listbadcases.mako	2008-09-12 10:10:27 UTC (rev 152)
@@ -15,10 +15,9 @@
              'cm_ende':u'Fehlende Pflichtfeldangaben für Fälle in beendeter "Case-Management" Phase',
              'nachbetreuung_start':u'Fehlende Pflichtfeldangaben für Fälle in laufender "Nachbetreuungs" Phase',
              'nachbetreuung_ende':u'Fehlende Pflichtfeldangaben für Fälle in beendeter "Nachbetreuungs'}
-  # ignore search of inconsistent cases which do not intersect with the given
-  # timeframe (filter out old cases)
+  # ignore search of inconsistent cases which older than the given
+  # date(filter out old cases)
   start_date = '2008-09-01'
-  end_date = '2011-09-01'
 %>
 <%inherit file="../main.mako" />
 <div>
@@ -44,7 +43,7 @@
             <input type="hidden" name="show_own" value="1">
             <input type="hidden" name="show_open" value="1">
             % if regexpr.match(k):
-              <input type="hidden" name="search_str" value="inconsistency:${k};interval_start_date:'${start_date}';interval_end_date:'${end_date}'">
+              <input type="hidden" name="search_str" value="inconsistency:${k};only_cases_after:${start_date}'">
             % else:
               <input type="hidden" name="search_str" value="inconsistency:${k}">
             % endif



More information about the Mpuls-commits mailing list