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

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Thu Feb 25 15:17:24 CET 2010


Author: torsten
Date: 2010-02-25 15:17:24 +0100 (Thu, 25 Feb 2010)
New Revision: 1784

Modified:
   wasko/branches/2.0/mpulsweb/controllers/case.py
Log:
* mpulsweb/controllers/case.py (CaseController.markForAnonymize):
  Completed logic to mark case for anonymization.	


Modified: wasko/branches/2.0/mpulsweb/controllers/case.py
===================================================================
--- wasko/branches/2.0/mpulsweb/controllers/case.py	2010-02-25 14:14:44 UTC (rev 1783)
+++ wasko/branches/2.0/mpulsweb/controllers/case.py	2010-02-25 14:17:24 UTC (rev 1784)
@@ -2,7 +2,7 @@
 import logging
 import formencode
 
-from pylons import request, response, session, tmpl_context as c
+from pylons import request, response, session, tmpl_context as c, app_globals as g
 from pylons.controllers.util import abort, redirect_to
 
 
@@ -10,13 +10,26 @@
 from mpulsweb.lib.navigation import get_navigation
 from mpulsweb.lib.security import checkRole
 from mpulsweb.lib.validators import SetStandinForm, SetEditorForm
-from mpulsweb.lib.anonymize import check_state, AnonymizeCheckException 
+from mpulsweb.lib.anonymize import check_state, anonymize, \
+    AnonymizeCheckException, determineAnonymizedCaseEndPhase
 from mpulsweb.model.user import UserGroupList, UserListObject
 
 from mpulsweb.controllers.formularpage import get_rendered_page
 
-MARKANONYMIZE_INCOMPLETE_PHASE_FAILED = u"""Anonymisierung nicht möglich."""
+ANONYMIZE_CONFIRM = u"""Fallakte anonymisieren?"""
+MARKANONYMIZE_CONFIRM_TEXT = u"""\
+<p>Wollen Sie wirklich die Fallakte zum Anonymisieren freigeben? Die
+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>"""
 
+MARKANONYMIZE_FAILED = u"""Anonymisierung nicht möglich."""
+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."""
+
 log = logging.getLogger(__name__)
 
 class CaseController(BaseController):
@@ -55,7 +68,6 @@
     #
     # Anonymize
     #
-
     @checkRole('cm_ka')
     def markForAnonymize(self, id, confirmed):
         id = self._checkInt(id)
@@ -66,40 +78,31 @@
         try:
             check_state(case)
         except AnonymizeCheckException, e:
-            c.dialog_title =  MARKANONYMIZE_INCOMPLETE_PHASE_FAILED
+            c.dialog_title =  MARKANONYMIZE_FAILED
             c.dialog_text  =  e.value 
-            return render('/casemanagement/dialogs/failed_markanonymize_phase_incomplete.mako')
-        return "OK"
+            c.url_ok = "/case/digest/%s" % id
+            return render('/casemanagement/dialogs/failed_markanonymize.mako')
 
-        ## Check if the case is in a consistent state (all required fields
-        ## are filled)
-        #if ((not case.getState().phasesAreConsistent()
-        #     or not case.getState().phasesAreCompleted())
-        #    and case.isYoungerThan(INCONSISTENCY_CHECK_AFTER)):
-        #    c.notification_for = MARKANONYMIZE_INCOMPLETE_PHASE_FAILED
-        #    if case.getState().getPhase() in (CLEAR_START, CLEAR_ENDE):
-        #        c.notification_text = \
-        #                    MARKANONYMIZE_CLEARING_PHASE_FAILED_TEXT
-        #    else:
-        #        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:
-        #        _completeAnonymizedCase(case)
-        #        c.success_for = MARKANONYMIZE_SUCCESS
-        #        c.success_text = MARKANONYMIZE_SUCCESS_TEXT
-        #        c.url_ok = h.url_for(controller="/case_overview")
-        #        return render('/casemanagement/dialogs/success_markanonymize.mako')
-        #else:
-        #    c.confirm_for = ANONYMIZE_CONFIRM
-        #    c.question = MARKANONYMIZE_CONFIRM_TEXT % \
-        #          PHASE_DESCRIPTIONS[_determineAnonymizedCaseEndPhase(case)]
-        #    c.url_yes = "/case/markForAnonymize/%s/1" % id
-        #    c.url_no = "/case/digest/%s" % id
-        #    return render('/casemanagement/dialogs/confirm_markanonymize.mako')
+        # 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
+            # after anonymization.
+            anonymize(case)
+            c.dialog_title = MARKANONYMIZE_SUCCESS
+            c.dialog_text = MARKANONYMIZE_SUCCESS_TEXT
+            c.url_ok = h.url_for(controller="/case_overview")
+            state = case.getState().setState(4)
+            return render('/casemanagement/dialogs/success_markanonymize.mako')
+        else:
+            # Get description of the phase which will be set after anonymisation
+            pdescriptions = g.mpuls_config.get('phases', 'description')[0]
+            phase = pdescriptions.get(determineAnonymizedCaseEndPhase(case))
+            c.dialog_title = ANONYMIZE_CONFIRM
+            c.dialog_text = MARKANONYMIZE_CONFIRM_TEXT % phase
+            c.url_yes = "/case/markForAnonymize/%s/1" % id
+            c.url_no = "/case/digest/%s" % id
+            return render('/casemanagement/dialogs/confirm_markanonymize.mako')
 
     ##@checkRole('admin_ka')
     ##def anonymize(self, id, confirmed):



More information about the Mpuls-commits mailing list