[Mpuls-commits] r148 - in waska/trunk: . waskaweb/config waskaweb/controllers waskaweb/model waskaweb/templates/casemanagement/dialogs

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Wed Sep 10 17:51:27 CEST 2008


Author: torsten
Date: 2008-09-10 17:51:25 +0200 (Wed, 10 Sep 2008)
New Revision: 148

Added:
   waska/trunk/waskaweb/templates/casemanagement/dialogs/failed_markanonymize_phase_incomplete.mako
   waska/trunk/waskaweb/templates/casemanagement/dialogs/failed_markanonymize_phase_incomplete_from_overview.mako
Modified:
   waska/trunk/ChangeLog.txt
   waska/trunk/waskaweb/config/routing.py
   waska/trunk/waskaweb/controllers/case.py
   waska/trunk/waskaweb/controllers/case_overview.py
   waska/trunk/waskaweb/model/case.py
   waska/trunk/waskaweb/model/phases_factory.py
Log:
Anonymisation is now only possible when the required fields for the current phase are complete


Modified: waska/trunk/ChangeLog.txt
===================================================================
--- waska/trunk/ChangeLog.txt	2008-09-09 12:38:53 UTC (rev 147)
+++ waska/trunk/ChangeLog.txt	2008-09-10 15:51:25 UTC (rev 148)
@@ -1,3 +1,21 @@
+2008-09-10	Torsten Irlaender  <torsten.irlaender at intevation.de>
+
+	Anonymisation is now only possible when the required fields for the
+	current phase are complete
+
+	* waskaweb/model/phases_factory.py,
+	  waskaweb/model/case.py,
+	  waskaweb/config/routing.py,
+	  waskaweb/controllers/case_overview.py,
+	  waskaweb/controllers/case.py,
+	  waskaweb/templates/casemanagement/dialogs/failed_markanonymize_phase_incomplete_from_overview.mako,
+	  waskaweb/templates/casemanagement/dialogs/failed_markanonymize_phase_incomplete.mako:
+	  Added check in markAnonymize controllers to check if the required
+	  fields for the current phase is complete. If not the we raise a
+	  notifiction dialog, which informs the user on that fact. Incomplete
+	  cases will be silently ignored in casebundles as it is done already
+	  for invalid case-states.
+
 2008-09-09	Torsten Irlaender  <torsten.irlaender at intevation.de>
 
 	Added link to create a new logbook entry when switching the phase of a

Modified: waska/trunk/waskaweb/config/routing.py
===================================================================
--- waska/trunk/waskaweb/config/routing.py	2008-09-09 12:38:53 UTC (rev 147)
+++ waska/trunk/waskaweb/config/routing.py	2008-09-10 15:51:25 UTC (rev 148)
@@ -53,6 +53,7 @@
     map.connect('case/close/:id/:confirmed', controller="case", action="close")
     map.connect('case/select/:id/:confirmed', controller="case", action="select")
     map.connect('case/keepActive/:id/:confirmed', controller="case", action="keepActive")
+    map.connect('case/phase/:id/:confirmed', controller="case", action="phase")
     map.connect('case/printAll/:id/:empty', controller="case", action="printAll", empty=0)
     map.connect('case/showAppointment/:id/:confirmed', controller="case", action="showAppointment", confirmed=1)
     map.connect('case/anonymize/:id/:confirmed', controller="case", action="anonymize")

Modified: waska/trunk/waskaweb/controllers/case.py
===================================================================
--- waska/trunk/waskaweb/controllers/case.py	2008-09-09 12:38:53 UTC (rev 147)
+++ waska/trunk/waskaweb/controllers/case.py	2008-09-10 15:51:25 UTC (rev 148)
@@ -114,6 +114,8 @@
 MARKANONYMIZE_SUCCESS = u"""Fallakte wurde zur Anonymisierung freigegeben!"""
 MARKANONYMIZE_SUCCESS_TEXT = u"""Die Fallakten wurde zur Anonymisierung freigeben und liegt der Administration zur endgültigen Anonymisierung vor. Bitte klicken Sie auf "OK", um zur Fallaktenübersicht fortzufahren."""
 
+MARKANONYMIZE_INCOMPLETE_PHASE_FAILED = u"""Anonymisierung nicht möglich, da Angaben in einem oder mehren Pflichtfeldern fehlen!"""
+MARKANONYMIZE_INCOMPLETE_PHASE_FAILED_TEXT = u"""Für diese Fallakte wurden noch nicht alle nötigen Pflichtfeldangaben für die aktuelle Phase angegeben. Eine Anonymisierung ist daher nicht möglich.<br>Bitte tragen Sie die Daten ein und Wiederholen Sie den Vorgang. Klicken Sie auf "OK", um fortzufahren."""
 IMPORT_FAILED = u"""Fallakte wurde nicht importiert!"""
 IMPORT_FAILED_TEXT = u"""Bei dem Importieren der Datei ist ein Fehler aufgetreten. Es konnten keine Daten der Fallakte importiert werden. Klicken Sie auf "OK", um zum Import-Dialog fortzufahren."""
 
@@ -1250,6 +1252,13 @@
             confirmed = self._checkBool(confirmed)
             c.ds_id   = id
             case = load_case(id)
+            # Check if the case is in a consistent state (all required fields
+            # are filled)
+            if not case.getState().phasesAreConsistent():
+                c.notification_for  = MARKANONYMIZE_INCOMPLETE_PHASE_FAILED 
+                c.notification_text = MARKANONYMIZE_INCOMPLETE_PHASE_FAILED_TEXT
+                c.url_ok            = h.url_for(controller="/case_overview")
+                return render('/casemanagement/dialogs/failed_markanonymize_phase_incomplete_from_overview.mako')
             if confirmed == 1:
                 state = case.getState().setState(4)
                 if state:
@@ -1274,6 +1283,13 @@
             c.ds_id   = id
             case = load_case(id)
             c.form_navigation = self._getFormNavigation()
+            # Check if the case is in a consistent state (all required fields
+            # are filled)
+            if not case.getState().phasesAreConsistent():
+                c.notification_for  = MARKANONYMIZE_INCOMPLETE_PHASE_FAILED 
+                c.notification_text = MARKANONYMIZE_INCOMPLETE_PHASE_FAILED_TEXT
+                c.url_ok            = "/case/digest/%s" % id
+                return render('/casemanagement/dialogs/failed_markanonymize_phase_incomplete.mako')
             if confirmed == 1:
                 state = case.getState().setState(4)
                 if state:

Modified: waska/trunk/waskaweb/controllers/case_overview.py
===================================================================
--- waska/trunk/waskaweb/controllers/case_overview.py	2008-09-09 12:38:53 UTC (rev 147)
+++ waska/trunk/waskaweb/controllers/case_overview.py	2008-09-10 15:51:25 UTC (rev 148)
@@ -398,7 +398,7 @@
 
             if action == 'markanonymize':
                 # Fiter out case which are not open(1) or inavtice (2)
-                case_bundle = self._filterBundle(case_bundle, (1,2))
+                case_bundle = self._filterBundle(case_bundle, (1,2), filter_inconsistent=True)
                 if case_bundle.isEmpty(): return self._emptyListError()
                 session['casebundle'] = case_bundle
                 session.save()
@@ -467,10 +467,14 @@
             return htmlfill.render(unicode(form, 'utf-8'), c.form_result, c.form_errors, auto_insert_errors=False)
         return self.overview()
 
-    def _filterBundle(self, case_bundle, allowedstates, filtered_cases=None):
+    def _filterBundle(self, case_bundle, allowedstates, filtered_cases=None, filter_inconsistent=False):
+        '''Returns a filtered CaseBundle. kiltering can be done on states and on inconsistent cases (not all required fields are filled for current phase)'''
         filtered = []
         for case in case_bundle.getCases(filtered_cases):
-            if case.getState().getState() in allowedstates:
+            state = case.getState()
+            if filter_inconsistent and not state.phasesAreConsistent():
+                continue
+            if state.getState() in allowedstates:
                 filtered.append(case.id)
         case_bundle = CaseBundle(filtered)
         return case_bundle

Modified: waska/trunk/waskaweb/model/case.py
===================================================================
--- waska/trunk/waskaweb/model/case.py	2008-09-09 12:38:53 UTC (rev 147)
+++ waska/trunk/waskaweb/model/case.py	2008-09-10 15:51:25 UTC (rev 148)
@@ -54,7 +54,7 @@
 from waskaweb.model.document import listDocuments 
 
 from waskaweb.model.phase_transition import phase_description
-from waskaweb.model.phases_factory   import RequiredFields
+from waskaweb.model.phases_factory   import RequiredFields, phases_pairs
 
 from waskaweb.lib.helpers import dd_mm_yyyy_HH_MM, dd_mm_YYYY
 
@@ -1148,6 +1148,24 @@
     def getPhaseDescription(self):
         return phase_description(self.phase)
 
+    def phasesAreConsistent(self):
+        '''Returns True when the required fields for the current phase are
+        complete. Else False'''
+        case = CaseFactory().loadById(self.master_id) # Ugly we need to load the case here :(
+        rf = case.getRequiredFields()
+        cf = self.getPhase()
+        p_pairs = phases_pairs(rf, cf)
+        for pair in p_pairs:
+            p1, p2 = pair.getStart(), pair.getEnd()
+            # Find current phase
+            if p1.isRunning():
+                if not p1.isRecursiveComplete():
+                    return False
+            elif p2.isRunning():
+                if not p1.isRecursiveComplete():
+                    return False
+        return True
+
     def getAccessTime(self, format=None):
         if format:
             try:

Modified: waska/trunk/waskaweb/model/phases_factory.py
===================================================================
--- waska/trunk/waskaweb/model/phases_factory.py	2008-09-09 12:38:53 UTC (rev 147)
+++ waska/trunk/waskaweb/model/phases_factory.py	2008-09-10 15:51:25 UTC (rev 148)
@@ -121,7 +121,6 @@
 
         self.phases = phases
         self.times  = times
-            
         return phases
 
     def loadTimes(self, ds_id, cur):

Added: waska/trunk/waskaweb/templates/casemanagement/dialogs/failed_markanonymize_phase_incomplete.mako
===================================================================
--- waska/trunk/waskaweb/templates/casemanagement/dialogs/failed_markanonymize_phase_incomplete.mako	2008-09-09 12:38:53 UTC (rev 147)
+++ waska/trunk/waskaweb/templates/casemanagement/dialogs/failed_markanonymize_phase_incomplete.mako	2008-09-10 15:51:25 UTC (rev 148)
@@ -0,0 +1,8 @@
+## -*- coding: utf-8 -*- 
+<%inherit file="/casemanagement/main.mako" />
+<%def name="buildNavipath()">
+  ${parent.buildNavipath()}
+  <li><a href="/case/select/${session.get('case').id}/1">${_('cm_np_select')}</a></li>
+  <li><a href="#">${_('cm_np_anonymize')}</a></li>
+</%def>
+<%include file="../../dialogs/notification.mako" />

Added: waska/trunk/waskaweb/templates/casemanagement/dialogs/failed_markanonymize_phase_incomplete_from_overview.mako
===================================================================
--- waska/trunk/waskaweb/templates/casemanagement/dialogs/failed_markanonymize_phase_incomplete_from_overview.mako	2008-09-09 12:38:53 UTC (rev 147)
+++ waska/trunk/waskaweb/templates/casemanagement/dialogs/failed_markanonymize_phase_incomplete_from_overview.mako	2008-09-10 15:51:25 UTC (rev 148)
@@ -0,0 +1,8 @@
+## -*- coding: utf-8 -*- 
+<%inherit file="/main.mako" />
+<%def name="buildNavipath()">
+  ${parent.buildNavipath()}
+  <li><a href="/case/select/${session.get('case').id}/1">${_('cm_np_select')}</a></li>
+  <li><a href="#">${_('cm_np_anonymize')}</a></li>
+</%def>
+<%include file="/dialogs/notification.mako" />



More information about the Mpuls-commits mailing list