[Mpuls-commits] r5241 - in base/trunk: . mpulsweb/controllers mpulsweb/templates/casebundle/dialogs

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Thu Aug 18 16:37:38 CEST 2011


Author: bh
Date: 2011-08-18 16:37:35 +0200 (Thu, 18 Aug 2011)
New Revision: 5241

Added:
   base/trunk/mpulsweb/templates/casebundle/dialogs/failure_anonymize.mako
Modified:
   base/trunk/ChangeLog
   base/trunk/mpulsweb/controllers/case_bundle.py
Log:
* mpulsweb/controllers/case_bundle.py
(CaseBundleController.markAnonymize): Improve error reporting. The
case bundle methods like markAnonymize return for how many cases
in the bundle the action could be performed successfully. The old
code always presented the result as success, although it at least
indicated how many cases were marked for anonymization
successfully. The new code makes this more obvious. This is
necessary for the meta server support because now it's more likely
that marking for anonymization fails because it may involve
uploading data to the meta-server.

* mpulsweb/templates/casebundle/dialogs/failure_anonymize.mako:
New. Template for the mark anonymize error message.


Modified: base/trunk/ChangeLog
===================================================================
--- base/trunk/ChangeLog	2011-08-18 13:14:22 UTC (rev 5240)
+++ base/trunk/ChangeLog	2011-08-18 14:37:35 UTC (rev 5241)
@@ -1,3 +1,19 @@
+2011-08-18  Bernhard Herzog  <bh at intevation.de>
+
+	* mpulsweb/controllers/case_bundle.py
+	(CaseBundleController.markAnonymize): Improve error reporting. The
+	case bundle methods like markAnonymize return for how many cases
+	in the bundle the action could be performed successfully. The old
+	code always presented the result as success, although it at least
+	indicated how many cases were marked for anonymization
+	successfully. The new code makes this more obvious. This is
+	necessary for the meta server support because now it's more likely
+	that marking for anonymization fails because it may involve
+	uploading data to the meta-server.
+
+	* mpulsweb/templates/casebundle/dialogs/failure_anonymize.mako:
+	New. Template for the mark anonymize error message.
+
 2011-08-17  Bernhard Herzog  <bh at intevation.de>
 
 	* mpulsweb/controllers/case.py (CaseController.markForDelete): Use

Modified: base/trunk/mpulsweb/controllers/case_bundle.py
===================================================================
--- base/trunk/mpulsweb/controllers/case_bundle.py	2011-08-18 13:14:22 UTC (rev 5240)
+++ base/trunk/mpulsweb/controllers/case_bundle.py	2011-08-18 14:37:35 UTC (rev 5241)
@@ -327,31 +327,14 @@
             c.url_no = url_for(controller='/case_overview')
             return render('/casemanagement/dialogs/confirm.mako')
 
-     # ANONYMIZE
+    # ANONYMIZE
     @checkRole(('cm'))
     def markAnonymize(self, confirmed):
         confirmed = self._checkBool(confirmed)
         c.context = "../main.mako"
         case_bundle = session.get('casebundle')
-        if confirmed == 1:
-            num = case_bundle.markAnonymize()
-            c.success_for = ungettext(u"Case successfully cleared for"
-                                      u" anonymisation!",
-                                      u"Cases successfully cleared for"
-                                      u" anonymisation!",
-                                      num)
-            c.success_text = (
-                ungettext(u"%s case was cleared for anonymisation. It will be"
-                          u" presented to the administrators for review for"
-                          u" the definite anonymisation.",
-                          u"%s cases were cleared for anonymisation. They will"
-                          u" be presented to the administrators for review for"
-                          u" the definite anonymisation.", num) % num
-                + " " + _("Please click OK to continue."))
-            c.url_ok = url_for(controller='/case_overview')
-            del session['casebundle']
-            return render ('/casebundle/dialogs/success_anonymize.mako')
-        else:
+
+        if not confirmed:
             c.dialog_title = ungettext(u'Clear case for anonymisation?',
                                        u'Clear cases for anonymisation?',
                                        len(case_bundle.getCases()))
@@ -373,6 +356,58 @@
             c.url_no = url_for(controller='/case_overview')
             return render('/casebundle/dialogs/confirm_anonymize.mako')
 
+        successes = case_bundle.markAnonymize()
+        total = case_bundle.numDatasets()
+        failures = total - successes
+
+        if successes == total:
+            c.dialog_title = ungettext(u"Case marked for anonymisation!",
+                                       u"Cases marked for anonymisation!",
+                                       num_cases)
+            c.dialog_text = (
+                ungettext(u"The selected case was successfully marked for"
+                          u" anonymisation. The administrators will review it"
+                          u" and perform for the final anonymisation.",
+                          u"All selected cases were successfully marked for"
+                          u" anonymisation. The administrators will review them"
+                          u" and perform for the final anonymisation.",
+                          num_cases)
+                + " " + _("Please click OK to continue."))
+            template = '/casebundle/dialogs/success_anonymize.mako'
+        elif successes > 0:
+            # successes != total and successes > 0 means total
+            # is also greater than 1, so we can always assume the
+            # plural when talking about all selected cases
+            c.dialog_title = _(u"Not all cases marked for anonymisation!")
+            c.dialog_text = (
+                ungettext(u"One of the selected cases could not be"
+                          u" marked for anonymisation."
+                          u" The administrators will review the other cases"
+                          u" and perform the final anonymisation ",
+                          u"%(failures)s of the selected cases could"
+                          u" not be marked for anonymisation."
+                          u" The administrators will review the other cases"
+                          u" and perform the final anonymisation.",
+                          failures)
+                % dict(failures=failures)
+                + " " + _("Please click OK to continue."))
+            template = '/casebundle/dialogs/failure_anonymize.mako'
+        else:
+            c.dialog_title = ungettext(u"Case not marked for anonymisation.",
+                                       u"Cases not marked for anonymisation.",
+                                       total)
+            c.dialog_text = (ungettext(u"The selected case was not marked for"
+                                       u" anonymisation.",
+                                       u"None of the selected cases were marked"
+                                       u" for anonymisation.",
+                                       total)
+                             + " " + _("Please click OK to continue."))
+            template = '/casebundle/dialogs/failure_anonymize.mako'
+
+        c.url_ok = url_for(controller='/case_overview')
+        del session['casebundle']
+        return render(template)
+
     @checkRole(('admin'))
     def anonymize(self, confirmed):
         confirmed = self._checkBool(confirmed)

Added: base/trunk/mpulsweb/templates/casebundle/dialogs/failure_anonymize.mako
===================================================================
--- base/trunk/mpulsweb/templates/casebundle/dialogs/failure_anonymize.mako	2011-08-18 13:14:22 UTC (rev 5240)
+++ base/trunk/mpulsweb/templates/casebundle/dialogs/failure_anonymize.mako	2011-08-18 14:37:35 UTC (rev 5241)
@@ -0,0 +1,8 @@
+## -*- coding: utf-8 -*- 
+<%inherit file="/main.mako" />
+<%def name="buildNavipath()">
+  ${parent.buildNavipath()}
+  <li><a href="${h.url_for(controller='/case')}">${_('Case Management')}</a></li>
+  <li><a href="#">${_('Anonymize case document')}</a></li>
+</%def>
+<%include file="../../dialogs/failed.mako" />



More information about the Mpuls-commits mailing list