[Mpuls-commits] r5245 - in base/trunk: . mpulsweb/controllers mpulsweb/templates/casebundle/dialogs
scm-commit@wald.intevation.org
scm-commit at wald.intevation.org
Thu Aug 18 19:32:24 CEST 2011
Author: bh
Date: 2011-08-18 19:32:23 +0200 (Thu, 18 Aug 2011)
New Revision: 5245
Added:
base/trunk/mpulsweb/templates/casebundle/dialogs/failure_delete_admin.mako
Modified:
base/trunk/ChangeLog
base/trunk/mpulsweb/controllers/case_bundle.py
Log:
* mpulsweb/controllers/case_bundle.py
(CaseBundleController.delete): Improve error reporting. This is
basically the same as the improved error reporting implemented for
markAnonymize and anonymize including the performance improvement
achieved by fewer calls to case_bundle.getCases().
* mpulsweb/templates/casebundle/dialogs/failure_delete_admin.mako:
New. Template for the case bundle deletion error message.
Modified: base/trunk/ChangeLog
===================================================================
--- base/trunk/ChangeLog 2011-08-18 16:37:29 UTC (rev 5244)
+++ base/trunk/ChangeLog 2011-08-18 17:32:23 UTC (rev 5245)
@@ -1,6 +1,17 @@
2011-08-18 Bernhard Herzog <bh at intevation.de>
* mpulsweb/controllers/case_bundle.py
+ (CaseBundleController.delete): Improve error reporting. This is
+ basically the same as the improved error reporting implemented for
+ markAnonymize and anonymize including the performance improvement
+ achieved by fewer calls to case_bundle.getCases().
+
+ * mpulsweb/templates/casebundle/dialogs/failure_delete_admin.mako:
+ New. Template for the case bundle deletion error message.
+
+2011-08-18 Bernhard Herzog <bh at intevation.de>
+
+ * mpulsweb/controllers/case_bundle.py
(CaseBundleController.anonymize): Improve error reporting. This is
basically the same as the improved error reporting implemented for
markAnonymize. It already includes the performance improvement
Modified: base/trunk/mpulsweb/controllers/case_bundle.py
===================================================================
--- base/trunk/mpulsweb/controllers/case_bundle.py 2011-08-18 16:37:29 UTC (rev 5244)
+++ base/trunk/mpulsweb/controllers/case_bundle.py 2011-08-18 17:32:23 UTC (rev 5245)
@@ -296,37 +296,68 @@
confirmed = self._checkBool(confirmed)
c.context = "../main.mako"
case_bundle = session.get('casebundle')
- if confirmed == 1:
- num = case_bundle.delete()
- c.dialog_title = ungettext(u"Case successfully deleted.",
- u"Cases successfully deleted.",
- num)
- c.dialog_text = (ungettext(u"%s case was successfully deleted.",
- u"%s cases were successfully deleted.",
- num) % num
- + " " + _("Please click OK to continue."))
- c.url_ok = url_for(controller='/case_overview')
- del session['casebundle']
- return render('/casebundle/dialogs/success_delete_admin.mako')
- else:
+ total = case_bundle.numDatasets()
+
+ if not confirmed:
c.dialog_title = ungettext(u'Delete case?', u'Delete cases?',
- len(case_bundle.getCases()))
+ total)
c.dialog_text = (ungettext('Do you really want to delete the'
' following case?%s',
'Do you really want to delete the'
' following cases?%s',
- len(case_bundle.getCases()))
- % "\n".join(self._buildCaseList(case_bundle))) \
- + _("""Warning! On deleting the case all data will be erased
-irrecoverable!<br>Only delete the case if this case is <b>not needed for
-evaluations</b> anymore.<br><br>Do you want to delete the case from the
-server?""") + "<br><br>"
-
+ total)
+ % "\n".join(self._buildCaseList(case_bundle))
+ + _("Warning!"
+ " Deleting cases will erase all data of the"
+ " case irrecoverably!<br>\n"
+ "Only delete the case if this case is"
+ " <b>not needed for evaluations</b>"
+ " anymore.<br><br>\n"
+ "Do you want to delete the case from the"
+ " server?""")
+ + "<br><br>")
c.url_yes = url_for(controller='/case_bundle', action='delete',
confirmed=1)
c.url_no = url_for(controller='/case_overview')
return render('/casemanagement/dialogs/confirm.mako')
+ successes = case_bundle.delete()
+ failures = total - successes
+
+ if not failures:
+ c.dialog_title = ungettext(u"Case successfully deleted.",
+ u"Cases successfully deleted.",
+ total)
+ c.dialog_text = (
+ ungettext(u"The selected case was successfully deleted.",
+ u"All selected cases were successfully deleted.",
+ total)
+ + " " + _("Please click OK to continue."))
+ template = '/casebundle/dialogs/success_delete_admin.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 = _("Not all selected cases deleted")
+ c.dialog_text = (
+ ungettext(u"One of the selected cases could not be"
+ u" deleted.",
+ u"%(failures)d of the selected cases could not"
+ u" be deleted.",
+ failures) % dict(failures=failures)
+ + " " + _("Please click OK to continue."))
+ template = '/casebundle/dialogs/failure_delete_admin.mako'
+ else:
+ c.dialog_title = _(u"No Case not deleted.")
+ c.dialog_text = _(u"None of the selected cases could be deleted."
+ u" Please click OK to continue.")
+
+ template = '/casebundle/dialogs/failure_delete_admin.mako'
+
+ c.url_ok = url_for(controller='/case_overview')
+ del session['casebundle']
+ return render(template)
+
# ANONYMIZE
@checkRole(('cm'))
def markAnonymize(self, confirmed):
Added: base/trunk/mpulsweb/templates/casebundle/dialogs/failure_delete_admin.mako
===================================================================
--- base/trunk/mpulsweb/templates/casebundle/dialogs/failure_delete_admin.mako 2011-08-18 16:37:29 UTC (rev 5244)
+++ base/trunk/mpulsweb/templates/casebundle/dialogs/failure_delete_admin.mako 2011-08-18 17:32:23 UTC (rev 5245)
@@ -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="#">${_('Case document deleted!')}</a></li>
+</%def>
+<%include file="../../dialogs/failed.mako" />
More information about the Mpuls-commits
mailing list