[Mpuls-commits] r4618 - base/trunk/mpulsweb/controllers
scm-commit@wald.intevation.org
scm-commit at wald.intevation.org
Tue Feb 15 12:41:08 CET 2011
Author: torsten
Date: 2011-02-15 12:41:08 +0100 (Tue, 15 Feb 2011)
New Revision: 4618
Modified:
base/trunk/mpulsweb/controllers/case_bundle.py
Log:
* mpulsweb/controllers/case_bundle.py
(CaseBundleController.formletter): New function in casebundle to build
the export for different formletters. Basically show dialog for
download.
* mpulsweb/controllers/case_bundle.py
(CaseBundleController.formletterAction): Finally export data for
formletter.
Modified: base/trunk/mpulsweb/controllers/case_bundle.py
===================================================================
--- base/trunk/mpulsweb/controllers/case_bundle.py 2011-02-15 11:38:09 UTC (rev 4617)
+++ base/trunk/mpulsweb/controllers/case_bundle.py 2011-02-15 11:41:08 UTC (rev 4618)
@@ -16,6 +16,7 @@
from mpulsweb.lib.validators import BundleActionForm, SetBundleEditorForm, \
SetBundleStandinForm, ExportSelectorValidator
from mpulsweb.lib.helper.filters import NA
+from mpulsweb.lib.export import FormletterExport
from mpulsweb.model.user import UserGroupList, UserListObject, UserObject
from mpulsweb.model.case import MpulsCaseBundle, MpulsCaseOverview
from mpulsweb.model.phase import ConsistenceCheckException
@@ -172,6 +173,18 @@
if export_format in ("XML", "CSV", "XLS"):
return self.export(export_format)
+ if action.startswith("formletter"):
+ # allow formletter of cases that are active (1). For historical
+ # reasons, there's also the old now unused state 2 in
+ # the filter tuple.
+ case_bundle = self._filterBundle(case_bundle, (1, 2))
+ if case_bundle.isEmpty():
+ return self._empty_caselist()
+ session['casebundle'] = case_bundle
+ session.save()
+ letter_id = action.split(':')[1]
+ return self.formletter(letter_id)
+
if action == 'evaluate':
case_bundle = self._filterBundle(case_bundle, (1, 4, 5))
if case_bundle.isEmpty():
@@ -521,6 +534,31 @@
elif exporttype == "CSV":
return self._download_data(export, "application/zip", "zip")
+ #FORMLETTER
+ def formletter(self, letterid):
+ case_bundle = session.get('casebundle')
+ num = len(case_bundle)
+ lettername = _('unknown')
+ for l in g.mpuls_config.get('case', 'formletter'):
+ if int(l.get('id')) == int(letterid):
+ lettername = l.get('name')
+ c.dialog_title= ungettext("%s Case was marked for formletter" % num,
+ "%s Cases were marked for formletter" % num,
+ num)
+ c.dialog_text = \
+ ungettext("%d case can be exported for formletter '%s'. Please click on 'Download' to download the exported data",
+ "%d cases can be exported for formletter '%s'. Please click on 'Download' to download the exported data",
+ num) % (num, lettername)
+ c.letterid = letterid
+ return render('/casebundle/dialogs/download_formletter.mako')
+
+ def formletterAction(self):
+ letter_id = request.params.get('letterid')
+ case_bundle = session.get('casebundle')
+ d = case_bundle.formletter(letter_id)
+ export = FormletterExport(d).export()
+ return self._download_data(export, "application/msexcel", "xls")
+
def _download_data(self, data, mime_type, extension, **extra):
disposition = 'attachment; filename="fallakten-export.%s"' % extension
data = paste.fileapp.DataApp(data,
More information about the Mpuls-commits
mailing list