[Mpuls-commits] r3670 - base/trunk/mpulsweb/controllers

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Thu Sep 16 12:03:32 CEST 2010


Author: torsten
Date: 2010-09-16 12:03:32 +0200 (Thu, 16 Sep 2010)
New Revision: 3670

Modified:
   base/trunk/mpulsweb/controllers/case.py
Log:
* mpulsweb/controllers/case.py (CaseController._markForAnonymize): Put
make_anonymizable in a try except block and show error dialog if
something goes wrong.


Modified: base/trunk/mpulsweb/controllers/case.py
===================================================================
--- base/trunk/mpulsweb/controllers/case.py	2010-09-16 10:02:47 UTC (rev 3669)
+++ base/trunk/mpulsweb/controllers/case.py	2010-09-16 10:03:32 UTC (rev 3670)
@@ -6,6 +6,8 @@
 from pylons import request, tmpl_context as c, app_globals as g
 from pylons.controllers.util import redirect_to
 
+from formed.instance.tree import SetDataException
+
 from mpulsweb.lib.translation import _, ungettext
 from mpulsweb.lib.base import BaseController, render, session, h
 from mpulsweb.lib.security import checkRole
@@ -178,13 +180,25 @@
         # Ok, show confirmation dialog if the user really wants to anonymize the
         # case.
         if confirmed == 1:
-            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)
-            session['render_mode'] = 'ro'
-            session.save()
-            return render('/casemanagement/dialogs/success_markanonymize.mako')
+            try:
+                c.dialog_title = MARKANONYMIZE_SUCCESS
+                c.dialog_text = MARKANONYMIZE_SUCCESS_TEXT
+                c.url_ok = h.url_for(controller="/case_overview")
+                case.make_anonymizable()
+                state = case.getState().setState(4)
+                session['render_mode'] = 'ro'
+                session.save()
+                return render('/casemanagement/dialogs/success_markanonymize.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(controller='/case', action='select',
+                                     id=case.id, confirmed=1)
+                return render('/casemanagement/dialogs/failed_markanonymize.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