[Mpuls-commits] r572 - in waska/trunk: . waskaweb/controllers waskaweb/model
scm-commit@wald.intevation.org
scm-commit at wald.intevation.org
Fri Aug 14 12:05:19 CEST 2009
Author: frank
Date: 2009-08-14 12:05:18 +0200 (Fri, 14 Aug 2009)
New Revision: 572
Modified:
waska/trunk/ChangeLog.txt
waska/trunk/waskaweb/controllers/case.py
waska/trunk/waskaweb/controllers/case_overview.py
waska/trunk/waskaweb/model/case.py
waska/trunk/waskaweb/model/phase_transition.py
waska/trunk/waskaweb/model/phases_factory.py
Log:
Introduce stronger constraints for anonymizing cases:
Only consistent cases with finished phase can be anonymized.
waskaweb/model/phase_transition.py
waskaweb/model/phases_factory.py
waskaweb/model/case.py
waskaweb/controllers/case_overview.py
waskaweb/controllers/case.py
Modified: waska/trunk/ChangeLog.txt
===================================================================
--- waska/trunk/ChangeLog.txt 2009-08-13 10:52:39 UTC (rev 571)
+++ waska/trunk/ChangeLog.txt 2009-08-14 10:05:18 UTC (rev 572)
@@ -1,3 +1,31 @@
+2009-08-14 Frank Koormann <frank.koormann at intevation.de>
+
+ Introduce stronger constraints for anonymizing cases:
+ Only consistent cases with finished phase can be anonymized.
+
+ * waskaweb/model/phase_transition.py (phase_end, phase_start):
+ New, functions to determine if the current phase is a start or end
+ part of a phase pair. The end part identifies, that a phase is
+ finished.
+
+ * waskaweb/model/phases_factory.py (currentPhase):
+ New, instantiate an object for the current phase.
+
+ * waskaweb/model/case.py (State.phasesAreCompleted):
+ New, returns True when the required fields for the ending of the
+ current phase pair are completed and the phase ist finished.
+
+ * waskaweb/controllers/case_overview.py
+ (CaseOverviewController._filterBundle):
+ Added phasesAreCompleted-constraint.
+
+ * waskaweb/controllers/case.py:
+ MARKANONYMIZE_INCOMPLETE_PHASE_FAILED_TEXT adapted.
+ (CaseController.markForAnonymizeFromOverview,
+ CaseController.markForAnonymize):
+ Added phasesAreCompleted-constraint.
+
+
2009-06-16 Torsten Irlaender <torsten.irlaender at intevation.de>
Fixed issue 689
Modified: waska/trunk/waskaweb/controllers/case.py
===================================================================
--- waska/trunk/waskaweb/controllers/case.py 2009-08-13 10:52:39 UTC (rev 571)
+++ waska/trunk/waskaweb/controllers/case.py 2009-08-14 10:05:18 UTC (rev 572)
@@ -116,7 +116,7 @@
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."""
-MARKANONYMIZE_INCOMPLETE_PHASE_FAILED_TEXT = u"""Eine Anonymisierung ist für dieser Fallakte derzeit nicht möglich. Bitte prüfen Sie, ob Sie Daten der Fallakte konsistent sind, und ob alle nötigen Pflichtfelder für die aktuelle oder zurückliegende Phasen ausgefüllt wurden. Erfüllen Sie die genannten Anforderungen zur Anonymisierung und Wiederholen Sie den Vorgang. Klicken Sie auf "OK", um fortzufahren."""
+MARKANONYMIZE_INCOMPLETE_PHASE_FAILED_TEXT = u"""<p>Eine Anonymisierung ist für dieser Fallakte derzeit nicht möglich: Es sind nur konsistente Fallakten mit beendeter Phase anonymisierbar.</p><p>Bitte prüfen Sie, ob die Daten der Fallakte konsistent sind und ob alle nötigen Pflichtfelder für die aktuelle oder zurückliegende Phasen ausgefüllt wurden.</p><p>Erfüllen Sie die genannten Anforderungen zur Anonymisierung und wiederholen Sie den Vorgang.<br>Klicken Sie auf "OK", um fortzufahren.</p>"""
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."""
@@ -1235,7 +1235,7 @@
case = load_case(id)
# Check if the case is in a consistent state (all required fields
# are filled)
- if not case.getState().phasesAreConsistent() and case.isYoungerThan(INCONSISTENCY_CHECK_AFTER):
+ if (not case.getState().phasesAreConsistent() or not case.getState().phasesAreCompleted()) and case.isYoungerThan(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")
@@ -1266,7 +1266,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() and case.isYoungerThan(INCONSISTENCY_CHECK_AFTER):
+ if (not case.getState().phasesAreConsistent() or not case.getState().phasesAreCompleted()) and case.isYoungerThan(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 2009-08-13 10:52:39 UTC (rev 571)
+++ waska/trunk/waskaweb/controllers/case_overview.py 2009-08-14 10:05:18 UTC (rev 572)
@@ -473,7 +473,7 @@
filtered = []
for case in case_bundle.getCases(filtered_cases):
state = case.getState()
- if filter_inconsistent and (not state.phasesAreConsistent() and case.isYoungerThan(INCONSISTENCY_CHECK_AFTER)):
+ if filter_inconsistent and ((not state.phasesAreConsistent() or not state.phasesAreCompleted()) and case.isYoungerThan(INCONSISTENCY_CHECK_AFTER)):
continue
if state.getState() in allowedstates:
filtered.append(case.id)
Modified: waska/trunk/waskaweb/model/case.py
===================================================================
--- waska/trunk/waskaweb/model/case.py 2009-08-13 10:52:39 UTC (rev 571)
+++ waska/trunk/waskaweb/model/case.py 2009-08-14 10:05:18 UTC (rev 572)
@@ -52,8 +52,8 @@
from waskaweb.model.statement import PrivacyStatement, AidPlanStatement, DiscretionStatement
from waskaweb.model.document import listDocuments
-from waskaweb.model.phase_transition import phase_description
-from waskaweb.model.phases_factory import RequiredFields, phases_pairs
+from waskaweb.model.phase_transition import phase_description, phase_end
+from waskaweb.model.phases_factory import RequiredFields, currentPhase, phases_pairs
from waskaweb.lib.helpers import dd_mm_yyyy_HH_MM, dd_mm_YYYY
@@ -1160,6 +1160,28 @@
if case.id in error_cases: return False
return True
+ def phasesAreCompleted(self):
+ '''Returns True if the required fields for the ending of the
+ current phase pair are completed and the phase ist finished.
+ Else False.'''
+ case = CaseFactory().loadById(self.master_id) # Ugly we need to load the case here :(
+ rf = case.getRequiredFields()
+ cf = self.getPhase()
+ current_phase = currentPhase(rf, cf)
+
+ # Check other inconsistency
+ # Search all cases with are inconsistent and then check if the current case is among them
+ user = session['USER_AUTHORIZED']
+ search_str = "state:1;state:2;state:4;state:5;bad:1;bad:2;bad:3;bad:4;bad:5;bad:6;bad:7;own:%s;standin:%s" % (user.id, user.id)
+ error_cases = Set(c.id for c in CaseOverview().search(search_str))
+ if case.id in error_cases: return False
+
+ if phase_end(cf) and current_phase.isRecursiveComplete():
+ return True
+ else:
+ return False
+
+
def getAccessTime(self, format=None):
if format:
try:
Modified: waska/trunk/waskaweb/model/phase_transition.py
===================================================================
--- waska/trunk/waskaweb/model/phase_transition.py 2009-08-13 10:52:39 UTC (rev 571)
+++ waska/trunk/waskaweb/model/phase_transition.py 2009-08-14 10:05:18 UTC (rev 572)
@@ -40,6 +40,9 @@
BERATUNG_START = 6
BERATUNG_ENDE = 7
+PHASE_STARTINGS = (CLEAR_START,CM_START,NB_START,BERATUNG_START)
+PHASE_ENDINGS = (CLEAR_ENDE,CM_ENDE,NB_ENDE,BERATUNG_ENDE)
+
# dictionary for GUI
PHASE_DESCRIPTIONS = {
UNKNOWN : u"Unbekannt",
@@ -130,4 +133,12 @@
print >> sys.stderr, "missing key in phase_neighbors:", ke
return False
+def phase_end(phase):
+ '''Return True if the current phase is the end part of a phase pair.'''
+ return phase in PHASE_ENDINGS
+
+def phase_start(phase):
+ '''Return True if the current phase is the start part of a phase pair.'''
+ return phase in PHASE_STARTINGS
+
# vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8:
Modified: waska/trunk/waskaweb/model/phases_factory.py
===================================================================
--- waska/trunk/waskaweb/model/phases_factory.py 2009-08-13 10:52:39 UTC (rev 571)
+++ waska/trunk/waskaweb/model/phases_factory.py 2009-08-14 10:05:18 UTC (rev 572)
@@ -317,4 +317,15 @@
return pairs
+def currentPhase(required_fields, current_phase):
+
+ symbol = phase_symbol(current_phase)
+ cur_phase = Phase(
+ current_phase,
+ True,
+ required_fields.isPhaseComplete(symbol),
+ required_fields.getPhaseTime(symbol),
+ required_fields.getLinkListForPhase(symbol, None, None))
+ return cur_phase
+
# vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8:
More information about the Mpuls-commits
mailing list