[Mpuls-commits] r1774 - wasko/branches/2.0/mpulsweb/controllers
scm-commit@wald.intevation.org
scm-commit at wald.intevation.org
Thu Feb 25 14:16:40 CET 2010
Author: torsten
Date: 2010-02-25 14:16:40 +0100 (Thu, 25 Feb 2010)
New Revision: 1774
Modified:
wasko/branches/2.0/mpulsweb/controllers/case.py
Log:
* mpulsweb/controllers/case.py (CaseController.markForAnonymize): New.
Use anonymize lib to check if teh case can be anonymized. This is
currently a dummy. check will always fail.
Modified: wasko/branches/2.0/mpulsweb/controllers/case.py
===================================================================
--- wasko/branches/2.0/mpulsweb/controllers/case.py 2010-02-25 13:14:39 UTC (rev 1773)
+++ wasko/branches/2.0/mpulsweb/controllers/case.py 2010-02-25 13:16:40 UTC (rev 1774)
@@ -10,10 +10,13 @@
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.model.user import UserGroupList, UserListObject
from mpulsweb.controllers.formularpage import get_rendered_page
+MARKANONYMIZE_INCOMPLETE_PHASE_FAILED = u"""Anonymisierung nicht möglich."""
+
log = logging.getLogger(__name__)
class CaseController(BaseController):
@@ -50,6 +53,92 @@
return render('/casemanagement/digest.mako')
#
+ # Anonymize
+ #
+
+ @checkRole('cm_ka')
+ def markForAnonymize(self, id, confirmed):
+ id = self._checkInt(id)
+ confirmed = self._checkBool(confirmed)
+ case = self._loadCase(id)
+
+ # First check if the case is in a state which allows anonymization
+ try:
+ check_state(case)
+ except AnonymizeCheckException, e:
+ c.dialog_title = MARKANONYMIZE_INCOMPLETE_PHASE_FAILED
+ c.dialog_text = e.value
+ return render('/casemanagement/dialogs/failed_markanonymize_phase_incomplete.mako')
+ return "OK"
+
+ ## 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')
+
+ ##@checkRole('admin_ka')
+ ##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')
+
+ ## 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')
+
+ #
# Printing
#
@checkRole(('admin_ka', 'cm_ka', 'pt_dlr'))
More information about the Mpuls-commits
mailing list