[Mpuls-commits] r163 - in waska/trunk: . waskaweb/controllers waskaweb/i18n/de/LC_MESSAGES waskaweb/lib waskaweb/model waskaweb/templates/casemanagement

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Mon Sep 15 15:54:36 CEST 2008


Author: torsten
Date: 2008-09-15 15:54:34 +0200 (Mon, 15 Sep 2008)
New Revision: 163

Modified:
   waska/trunk/ChangeLog.txt
   waska/trunk/waskaweb/controllers/case.py
   waska/trunk/waskaweb/controllers/case_overview.py
   waska/trunk/waskaweb/controllers/waska.py
   waska/trunk/waskaweb/i18n/de/LC_MESSAGES/waskaweb.po
   waska/trunk/waskaweb/lib/search.py
   waska/trunk/waskaweb/model/case.py
   waska/trunk/waskaweb/model/phases_factory.py
   waska/trunk/waskaweb/templates/casemanagement/phase.mako
Log:
Inconsistency check only for cases after 2008-09-01. Changed version string to
1.4.0 rc1


Modified: waska/trunk/ChangeLog.txt
===================================================================
--- waska/trunk/ChangeLog.txt	2008-09-15 10:12:02 UTC (rev 162)
+++ waska/trunk/ChangeLog.txt	2008-09-15 13:54:34 UTC (rev 163)
@@ -8,6 +8,24 @@
 	  path of the current phase. E.g if this is a CM case the "beratung"
 	  will not be displayed.
 
+	Changed Version string to 1.4.0 rc1
+
+	* waskaweb/i18n/de/LC_MESSAGES/waskaweb.po
+
+	Implemented ignoring consistency checks for cases before a the
+	01.09.2008
+
+	* waskaweb/model/phases_factory.py,
+	  waskaweb/model/case.py,
+	  waskaweb/controllers/case_overview.py,
+	  waskaweb/controllers/waska.py,
+	  waskaweb/controllers/case.py,
+	  waskaweb/lib/search.py,
+	  waskaweb/templates/casemanagement/phase.mako: Date of "erstgespräch"
+	  is loaded on creating a new case obejct. This date is then used for
+	  for determining if a case should be included in inconsistency
+	  checks.
+
 2008-09-15  Sascha L. Teichmann <sascha.teichmann at intevation.de>
 
 	* waskaweb/lib/security.py: Clean up usage db connection pool during

Modified: waska/trunk/waskaweb/controllers/case.py
===================================================================
--- waska/trunk/waskaweb/controllers/case.py	2008-09-15 10:12:02 UTC (rev 162)
+++ waska/trunk/waskaweb/controllers/case.py	2008-09-15 13:54:34 UTC (rev 163)
@@ -35,12 +35,13 @@
 import formencode
 
 from decorator import decorator
-from datetime  import datetime
+from datetime  import datetime, date
 
 from pylons import config
 
 from paste.httpexceptions        import HTTPNotFound
 from waskaweb.lib.base           import *
+from waskaweb.lib.search         import INCONSISTENCY_CHECK_AFTER
 from waskaweb.lib.evaluation     import *
 from waskaweb.lib.validators     import NewCaseForm, \
                                         SetStandinForm, \
@@ -473,6 +474,13 @@
 
         elif ti.page == "page_0":
             try:
+                erstgespraech = request.params.getone("erstgespraech")
+                try:
+                    d,m,y = erstgespraech.split('.')
+                    case_session.first_meeting = date(int(y), int(m), int(d))
+                except:
+                    traceback.print_exc(file=sys.stderr)
+                    case_session.first_meeting = None
                 case_session.knr = request.params.getone("kundennummer")
                 session.save()
             except KeyError:
@@ -735,8 +743,8 @@
 
                 current_phase = state.getPhase()
 
-                if not phase_neighbors(current_phase, new_phase):
-                    raise StandardError("Phasen sind nicht benachbart.")
+                #if not phase_neighbors(current_phase, new_phase):
+                #    raise StandardError("Phasen sind nicht benachbart.")
 
                 fields = case.getRequiredFields()
                 if not fields.isPhaseComplete(new_phase_symbol):
@@ -1254,7 +1262,7 @@
             case = load_case(id)
             # Check if the case is in a consistent state (all required fields
             # are filled)
-            if not case.getState().phasesAreConsistent():
+            if not case.getState().phasesAreConsistent() and case.isOlderThan(INCONSISTENCY_CHECK_AFTER):
                 c.notification_for  = MARKANONYMIZE_INCOMPLETE_PHASE_FAILED 
                 c.notification_text = MARKANONYMIZE_INCOMPLETE_PHASE_FAILED_TEXT
                 c.url_ok            = h.url_for(controller="/case_overview")
@@ -1285,7 +1293,7 @@
             c.form_navigation = self._getFormNavigation()
             # Check if the case is in a consistent state (all required fields
             # are filled)
-            if not case.getState().phasesAreConsistent():
+            if not case.getState().phasesAreConsistent() and case.isOlderThan(INCONSISTENCY_CHECK_AFTER):
                 c.notification_for  = MARKANONYMIZE_INCOMPLETE_PHASE_FAILED 
                 c.notification_text = MARKANONYMIZE_INCOMPLETE_PHASE_FAILED_TEXT
                 c.url_ok            = "/case/digest/%s" % id

Modified: waska/trunk/waskaweb/controllers/case_overview.py
===================================================================
--- waska/trunk/waskaweb/controllers/case_overview.py	2008-09-15 10:12:02 UTC (rev 162)
+++ waska/trunk/waskaweb/controllers/case_overview.py	2008-09-15 13:54:34 UTC (rev 163)
@@ -40,7 +40,7 @@
 from waskaweb.lib.security         import checkRole
 from waskaweb.model.case           import CaseOverview, CaseBundle
 from waskaweb.model.user           import UserListObject, UserObject, UserGroupList
-from waskaweb.lib.search           import build_inconsistency_type_querys 
+from waskaweb.lib.search           import INCONSISTENCY_CHECK_AFTER, build_inconsistency_type_querys 
 from waskaweb.controllers.CaseBase import CasebaseController
 
 from waskaweb.lib.exportselection  import CasePartsSelection
@@ -308,7 +308,7 @@
             for k,v in build_inconsistency_type_querys().iteritems():
                 # igonore checks on phases for old cases
                 if rexpr_phases.match(k):
-                    s = "state:1;state:2;own:%s;only_cases_after:'2008-09-01';inconsistency:%s" % (user.id, k)
+                    s = "state:1;state:2;own:%s;only_cases_after:'%s';inconsistency:%s" % (user.id, INCONSISTENCY_CHECK_AFTER, k)
                 else:
                     s = 'state:1;state:2;state:4;state:5;own:%s;inconsistency:%s' % (user.id, k)
                 l = CaseOverview().search(s)
@@ -472,7 +472,7 @@
         filtered = []
         for case in case_bundle.getCases(filtered_cases):
             state = case.getState()
-            if filter_inconsistent and not state.phasesAreConsistent():
+            if filter_inconsistent and (not state.phasesAreConsistent() and case.isOlderThan(INCONSISTENCY_CHECK_AFTER)):
                 continue
             if state.getState() in allowedstates:
                 filtered.append(case.id)

Modified: waska/trunk/waskaweb/controllers/waska.py
===================================================================
--- waska/trunk/waskaweb/controllers/waska.py	2008-09-15 10:12:02 UTC (rev 162)
+++ waska/trunk/waskaweb/controllers/waska.py	2008-09-15 13:54:34 UTC (rev 163)
@@ -32,6 +32,7 @@
 import logging
 
 from waskaweb.lib.base     import *
+from waskaweb.lib.search   import INCONSISTENCY_CHECK_AFTER 
 from waskaweb.lib.security import checkLogin, userIdentity, generateID, checkRole
 from waskaweb.model.user   import UserObject
 from waskaweb.model.case   import CaseOverview
@@ -91,7 +92,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;only_cases_after:'2008-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:'%s';own:%s" % (INCONSISTENCY_CHECK_AFTER, user.id)
 
         num_error_cases1 = len(CaseOverview().search(search_str1))
         num_error_cases2 = len(CaseOverview().search(search_str2))

Modified: waska/trunk/waskaweb/i18n/de/LC_MESSAGES/waskaweb.po
===================================================================
--- waska/trunk/waskaweb/i18n/de/LC_MESSAGES/waskaweb.po	2008-09-15 10:12:02 UTC (rev 162)
+++ waska/trunk/waskaweb/i18n/de/LC_MESSAGES/waskaweb.po	2008-09-15 13:54:34 UTC (rev 163)
@@ -530,7 +530,7 @@
 
 #: waskaweb/templates/main.mako:197
 msgid "footer_version"
-msgstr "12.09.2008 | Version 1.4.0 preview2"
+msgstr "15.09.2008 | Version 1.4.0 rc1"
 
 #: waskaweb/templates/main_login.mako:38
 #: waskaweb/templates/start/responsible.mako:149

Modified: waska/trunk/waskaweb/lib/search.py
===================================================================
--- waska/trunk/waskaweb/lib/search.py	2008-09-15 10:12:02 UTC (rev 162)
+++ waska/trunk/waskaweb/lib/search.py	2008-09-15 13:54:34 UTC (rev 163)
@@ -82,6 +82,7 @@
 
 INCONSISTENCY_LOCK = None
 INCONSISTENCY_TYPE_QUERY = None
+INCONSISTENCY_CHECK_AFTER = '2008-09-01'
 
 SEARCH_AGENCY_SQL = \
 """select count(m.id) as anzahl,

Modified: waska/trunk/waskaweb/model/case.py
===================================================================
--- waska/trunk/waskaweb/model/case.py	2008-09-15 10:12:02 UTC (rev 162)
+++ waska/trunk/waskaweb/model/case.py	2008-09-15 13:54:34 UTC (rev 163)
@@ -29,7 +29,7 @@
 
 import sys
 import re
-from datetime import datetime
+from datetime import date, datetime
 import traceback
 import psycopg2.extras
 import codecs
@@ -114,10 +114,9 @@
 FROM master_tbl_view WHERE id = %(id)s
 """
 
-LOAD_CASE_SQL = """SELECT name_1, vorname_1, bearbeiter_id, kundennummer from master_tbl_view WHERE id = %(id)s"""
+LOAD_CASE_SQL = """SELECT name_1, vorname_1, bearbeiter_id, kundennummer, erstgespraech from master_tbl_view WHERE id = %(id)s"""
 DELETE_CASE_SQL = """select delete_master_ds(%(id)s)""" 
 
-
 CREATE_CASE_SQL = """SELECT create_master_ds(%(uuid)s)"""
 INIT_CASE_SQL= """UPDATE page_0_view SET name_kompetenzagentur = %(ka_name)s, fkz = %(fkz)s, vorname = %(vorname)s, name = %(nachname)s WHERE id = %(id)s"""
 
@@ -384,11 +383,12 @@
             db.recycleConnection(conn, c)
 
         case.id = int(id)
-        case.last_name  = unicode(str(result.get('name_1', '')), 'utf-8')
-        case.first_name = unicode(str(result.get('vorname_1', '')), 'utf-8')
-        case.knr        = unicode(str(result.get('kundennummer', '')), 'utf-8')
-        case.editor     = result.get('bearbeiter_id', None)
-        case.state      = State(id)
+        case.last_name     = unicode(str(result.get('name_1', '')), 'utf-8')
+        case.first_name    = unicode(str(result.get('vorname_1', '')), 'utf-8')
+        case.knr           = unicode(str(result.get('kundennummer', '')), 'utf-8')
+        case.first_meeting = result.get('erstgespraech')
+        case.editor        = result.get('bearbeiter_id', None)
+        case.state         = State(id)
         return case
 
     def loadByName(self, id, first_name, last_name, knr, bearbeiter_id, einverst, s_id, s_state, s_access, s_cm_finished, s_cm_canceled):
@@ -747,6 +747,7 @@
         self.first_name        = None
         self.knr               = None
         self.state             = None
+        self.first_meeting     = None
         self.privacy_statement = False
 
         self.street = None 
@@ -787,18 +788,29 @@
         self.plz        = save_getone(params, "plz",       "")
         self.city       = save_getone(params, "wohnort",   "")
 
+    def getFirstMeeting(self):
+        return self.first_name
+
+    def isOlderThan(self, mydate):
+        y,m,d = mydate.split('-')
+        if self.first_meeting:
+            older = self.first_meeting > date(int(y), int(m), int(d))
+            return older
+        return True
+
     def save():
         pass
 
 class Case:
     def __init__(self):
-        self.id         = None 
-        self.first_name = None 
-        self.last_name  = None 
-        self.knr        = None 
-        self.editor     = None
-        self.standin    = None 
-        self.state      = None
+        self.id            = None 
+        self.first_name    = None 
+        self.last_name     = None 
+        self.knr           = None 
+        self.editor        = None
+        self.standin       = None 
+        self.state         = None
+        self.first_meeting = None
 
         self.digest                   = None
         self.page                     = None
@@ -847,6 +859,7 @@
         session.first_name        = self.first_name 
         session.knr               = self.knr
         session.state             = self.state
+        session.first_meeting     = self.first_meeting
         privacy_statement         = self.getPrivacyStatement()
         session.privacy_statement = privacy_statement.isSigned() 
         return session
@@ -1027,6 +1040,16 @@
         finally:
             db.recycleConnection(con, cur)
 
+    def getFirstMeeting(self):
+        return self.first_name
+
+    def isOlderThan(self, mydate):
+        y,m,d = mydate.split('-')
+        if self.first_meeting:
+            older = self.first_meeting > date(int(y), int(m), int(d))
+            return older
+        return True
+
 class State(object):
     '''This class store the state and the last accesstime of the case.
     Possible states are:

Modified: waska/trunk/waskaweb/model/phases_factory.py
===================================================================
--- waska/trunk/waskaweb/model/phases_factory.py	2008-09-15 10:12:02 UTC (rev 162)
+++ waska/trunk/waskaweb/model/phases_factory.py	2008-09-15 13:54:34 UTC (rev 163)
@@ -277,7 +277,6 @@
                 required_fields.isPhaseComplete(symbol),
                 required_fields.getPhaseTime(symbol),
                 required_fields.getLinkListForPhase(symbol, navigation, link))
-    print "Aktuelle Phase: %s" % cur_phase
 
     for p1, p2, description in PAIRS:
 
@@ -305,9 +304,9 @@
 
 
         # Only add phases which are on the path of the current phase
-        pairs.append(PhasePair(start, ende, description))
-        #if cur_phase.hasSuccessor(start) or cur_phase.hasPredecessor(start) or current_phase == p1: 
-        #    pairs.append(PhasePair(start, ende, description))
+        #pairs.append(PhasePair(start, ende, description))
+        if cur_phase.hasSuccessor(start) or cur_phase.hasPredecessor(start) or current_phase == p1: 
+            pairs.append(PhasePair(start, ende, description))
 
     for p in all.itervalues():
         for pred in phase_predecessors(p.phase):

Modified: waska/trunk/waskaweb/templates/casemanagement/phase.mako
===================================================================
--- waska/trunk/waskaweb/templates/casemanagement/phase.mako	2008-09-15 10:12:02 UTC (rev 162)
+++ waska/trunk/waskaweb/templates/casemanagement/phase.mako	2008-09-15 13:54:34 UTC (rev 163)
@@ -39,7 +39,7 @@
       </td>
       <td>${h.dd_mm_YYYY(p1.getTime(), '-/-')}</td>
       <td style="text-align:right">
-        % if p1.isRecursiveComplete() and not p1.isRunning() and p1.isNeighbor(c.current_phase) and not c.current_phase.hasPredecessor(p1):
+        % if (p1.isRecursiveComplete() and not p1.isRunning() and (p1.isNeighbor(c.current_phase) or c.current_phase.hasPredecessor(p1))) or not session.get('case').isOlderThan('2008-09-01'):
             <input type="submit" value="Start" name="${p1.getLabel()|h}">
         % else:
             <input type="submit" value="Start" name="${p1.getLabel()|h}"
@@ -58,7 +58,7 @@
       </td>
       <td class="table_row_h">${h.dd_mm_YYYY(p2.getTime(), '-/-')}</td>
       <td style="text-align:right" class="table_row_h">
-        % if p2.isRecursiveComplete() and p2.isNeighbor(c.current_phase) and not c.current_phase.hasPredecessor(p2):
+        % if (p2.isRecursiveComplete() and p2.isNeighbor(c.current_phase) and not c.current_phase.hasPredecessor(p2)) or not session.get('case').isOlderThan('2008-09-01'):
             <input type="submit" value="Ende" name="${p2.getLabel()|h}">
         % else:
             <input type="submit" value="Ende" name="${p2.getLabel()|h}" 



More information about the Mpuls-commits mailing list