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

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Wed May 5 17:32:16 CEST 2010


Author: torsten
Date: 2010-05-05 17:32:15 +0200 (Wed, 05 May 2010)
New Revision: 2667

Modified:
   wasko/branches/2.0/mpulsweb/controllers/privacy.py
Log:
* mpulsweb/controllers/privacy.py (PrivacyController.decline): Fetch
	SetDataException when making the case anonymizable.


Modified: wasko/branches/2.0/mpulsweb/controllers/privacy.py
===================================================================
--- wasko/branches/2.0/mpulsweb/controllers/privacy.py	2010-05-05 15:31:06 UTC (rev 2666)
+++ wasko/branches/2.0/mpulsweb/controllers/privacy.py	2010-05-05 15:32:15 UTC (rev 2667)
@@ -6,6 +6,8 @@
 
 from pylons.i18n import _
 
+from formed.instance.tree import SetDataException
+
 from mpulsweb.lib.security import checkRole
 from mpulsweb.lib.base import BaseController, render, c, h, session
 from mpulsweb.lib.anonymize import determineAnonymizedCaseEndPhaseName, \
@@ -13,7 +15,9 @@
 from mpulsweb.model.phase import ConsistenceCheckException
 
 from mpulsweb.controllers.case import MARKANONYMIZE_CONFIRM_TEXT, \
-     MARKANONYMIZE_SUCCESS, MARKANONYMIZE_SUCCESS_TEXT, MARKANONYMIZE_FAILED
+     MARKANONYMIZE_SUCCESS, MARKANONYMIZE_SUCCESS_TEXT, MARKANONYMIZE_FAILED, \
+     MARKANONYMIZE_FAILED_TEXT
+       
 
 HEADER = _("Set declaration of consent?")
 
@@ -120,13 +124,22 @@
             statement = case.getPrivacyStatement()
             statement.decline()
             # Mark case for anonymizion
-            case.getState().setState(4)
-            case.make_anonymizable()
+            try:
+                case.make_anonymizable()
+                c.dialog_title = MARKANONYMIZE_SUCCESS
+                c.dialog_text = MARKANONYMIZE_SUCCESS_TEXT
+                c.url_ok = h.url_for ('/case_overview')
+                return render('/privacy/dialogs/decline_success.mako')
+            except SetDataException, e:
+                errors = []
+                for k, values in e.errors.iteritems():
+                    for v in values:
+                        errors.append(v.msg)
+                c.dialog_title = MARKANONYMIZE_FAILED
+                c.dialog_text = MARKANONYMIZE_FAILED_TEXT % "<br>".join(errors) 
+                c.url_ok = h.url_for ('/case/select/%s/1' % case.id)
+                return render('/privacy/dialogs/decline_failed.mako')
 
-            c.dialog_title = MARKANONYMIZE_SUCCESS
-            c.dialog_text = MARKANONYMIZE_SUCCESS_TEXT
-            c.url_ok = h.url_for ('/case_overview')
-            return render('/privacy/dialogs/decline_success.mako')
         else:
             # Get description of the phase which will be set after anonymisation
             pdescriptions = g.mpuls_config.get('phases', 'description')[0]



More information about the Mpuls-commits mailing list