[Mpuls-commits] r1806 - wasko/branches/2.0/mpulsweb/controllers

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Thu Feb 25 16:49:46 CET 2010


Author: torsten
Date: 2010-02-25 16:49:46 +0100 (Thu, 25 Feb 2010)
New Revision: 1806

Modified:
   wasko/branches/2.0/mpulsweb/controllers/case.py
Log:
* mpulsweb/controllers/case.py (CaseController.anonymize): Implement
logic to anonymize case in case-controller.


Modified: wasko/branches/2.0/mpulsweb/controllers/case.py
===================================================================
--- wasko/branches/2.0/mpulsweb/controllers/case.py	2010-02-25 15:28:30 UTC (rev 1805)
+++ wasko/branches/2.0/mpulsweb/controllers/case.py	2010-02-25 15:49:46 UTC (rev 1806)
@@ -22,6 +22,16 @@
 Fallakte steht Ihnen danach nicht mehr zur Bearbeitung zur Verfügung und
 wird der Administration zur Anonymisierung vorgelegt.</p>
 <p><b>Die Fallakte wird in der Phase </b>'%s'<b> anonymisiert!</b>"""
+ANONYMIZE_CONFIRM_TEXT = u"""Wollen Sie wirklich die Fallakte anonymisieren
+und die personenbezogenen Daten unwiederbringlich verlieren?. Die
+Fallakte steht danach nicht mehr zur Bearbeitung zur Verfügung. Die
+anonymisierte Fallakte wird weiterhin in der Auswertung berücksichtigt
+werden."""
+ANONYMIZE_SUCCESS = u"""Fallakte anonymisiert!"""
+ANONYMIZE_SUCCESS_TEXT = u"""\
+Die personenbezogenen Daten der Fallakte wurden gelöscht und die
+Fallakte aus der Übersicht entfernt. Bitte klicken Sie auf "OK",
+um zur Fallaktenübersicht fortzufahren."""
 
 MARKANONYMIZE_FAILED = u"""Anonymisierung nicht möglich."""
 MARKANONYMIZE_SUCCESS = u"""Fallakte wurde zur Anonymisierung freigegeben!"""
@@ -83,7 +93,7 @@
             c.url_ok = "/case/digest/%s" % id
             return render('/casemanagement/dialogs/failed_markanonymize.mako')
 
-        # Ok show confirmation dialog if the user really wants to anonymize the
+        # Ok, show confirmation dialog if the user really wants to anonymize the
         # case.
         if confirmed == 1:
             # Anonymize case. Ensure that the case is in a consistent state
@@ -104,43 +114,37 @@
             c.url_no = "/case/digest/%s" % id
             return render('/casemanagement/dialogs/confirm_markanonymize.mako')
 
-    ##@checkRole('admin')
-    ##def anonymize(self, id, confirmed):
-    ##    id = self._checkInt(id)
-    ##    confirmed = self._checkBool(confirmed)
-    ##    # Check if the case is in a consistent state (all required fields
-    ##    # are filled also check if the phase is finished.)
-    ##    case = self._loadCase(id)
-    ##    if ((not case.getState().phasesAreConsistent()
-    ##         or not case.getState().phasesAreCompleted()
-    ##         or not case.getState().getPhase() in (CM_ENDE, NB_ENDE))
-    ##        and case.isYoungerThan(INCONSISTENCY_CHECK_AFTER)):
-    ##        c.failed_for = MARKANONYMIZE_INCOMPLETE_PHASE_FAILED
-    ##        if case.getState().getPhase() in (CLEAR_START, CLEAR_ENDE):
-    ##            c.failed_text = \
-    ##                        MARKANONYMIZE_CLEARING_PHASE_FAILED_TEXT
-    ##        else:
-    ##            c.failed_text = \
-    ##                        MARKANONYMIZE_INCOMPLETE_PHASE_FAILED_TEXT
-    ##        c.url_ok = "/case/digest/%s" % id
-    ##        return render('/casemanagement/dialogs/failed_anonymize.mako')
+    @checkRole('admin')
+    def anonymize(self, id, confirmed):
+        id = self._checkInt(id)
+        confirmed = self._checkBool(confirmed)
+        case = self._loadCase(id)
 
-    ##    if confirmed == 1:
-    ##        if case.anonymize():
-    ##            c.success_for = ANONYMIZE_SUCCESS
-    ##            c.success_text = ANONYMIZE_SUCCESS_TEXT
-    ##            c.url_ok = h.url_for(controller="/case_overview")
-    ##            return render('/casemanagement/dialogs/success_anonymize.mako')
-    ##        # TODO: Create Errorpage
-    ##        return "Error! Could not anonymize ds."
-    ##    else:
-    ##        c.context = "../main.mako"
-    ##        c.confirm_for = ANONYMIZE_CONFIRM
-    ##        c.question = ANONYMIZE_CONFIRM_TEXT
-    ##        c.url_yes = "/case/anonymize/%s/1" % id
-    ##        c.url_no = "/case/digest/%s" % id
-    ##        return render('/casemanagement/dialogs/confirm_anonymize.mako')
+        # First check if the case is in a state which allows anonymization 
+        try:
+            check_state(case)
+        except AnonymizeCheckException, e:
+            c.dialog_title =  MARKANONYMIZE_FAILED
+            c.dialog_text  =  e.value 
+            c.url_ok = "/case/digest/%s" % id
+            return render('/casemanagement/dialogs/failed_markanonymize.mako')
 
+        # Ok, show confirmation dialog if the user really wants to anonymize the
+        # case.
+        if confirmed == 1:
+            case.anonymize()
+            c.dialog_title = ANONYMIZE_SUCCESS
+            c.dialog_text = ANONYMIZE_SUCCESS_TEXT
+            c.url_ok = h.url_for(controller="/case_overview")
+            return render('/casemanagement/dialogs/success_anonymize.mako')
+        else:
+            c.context = "../main.mako"
+            c.dialog_title = ANONYMIZE_CONFIRM
+            c.dialog_text = ANONYMIZE_CONFIRM_TEXT
+            c.url_yes = "/case/anonymize/%s/1" % id
+            c.url_no = "/case/digest/%s" % id
+            return render('/casemanagement/dialogs/confirm_anonymize.mako')
+
     #
     # Printing
     #



More information about the Mpuls-commits mailing list