[Mpuls-commits] r2521 - wasko/branches/2.0/mpulsweb/controllers
scm-commit@wald.intevation.org
scm-commit at wald.intevation.org
Mon Apr 26 14:09:13 CEST 2010
Author: torsten
Date: 2010-04-26 14:09:13 +0200 (Mon, 26 Apr 2010)
New Revision: 2521
Modified:
wasko/branches/2.0/mpulsweb/controllers/case_bundle.py
Log:
Added actions to export casebundles
Modified: wasko/branches/2.0/mpulsweb/controllers/case_bundle.py
===================================================================
--- wasko/branches/2.0/mpulsweb/controllers/case_bundle.py 2010-04-26 12:08:31 UTC (rev 2520)
+++ wasko/branches/2.0/mpulsweb/controllers/case_bundle.py 2010-04-26 12:09:13 UTC (rev 2521)
@@ -3,6 +3,7 @@
import logging
import formencode
+import paste
from pylons import app_globals as g
from pylons.i18n import _, ungettext
@@ -77,6 +78,14 @@
Es wurden %s Fallakten erfolgreich wiederhergestellt. Bitte klicken Sie
auf "OK", um fortzufahren."""
+DIALOG_CONFIRM_EXPORT = u'''Fallakten exportieren?'''
+DIALOG_CONFIRM_EXPORT_EXPLAINATION = u'''\
+Wollen Sie wirklich die folgenden Fallakten exportieren?%s'''
+EXPORT_SUCCESS_HEADER = u"""Fallakten exportiert!"""
+EXPORT_SUCCESS_TEXT = u"""\
+Es wurden %s Fallakten erfolgreich exportiert. Bitte klicken Sie
+auf "OK", um fortzufahren."""
+
TRANSFER_SUCCESS_HEADER = u"""Bearbeitung übertragen!"""
TRANSFER_SUCCESS_TEXT = u"""\
Es wurden %s Fallakten erfolgreich an %s %s übertragen. Bitte klicken
@@ -205,6 +214,36 @@
return render('/casebundle/editor.mako')
+ if action == 'exportXML':
+ # Fiter out case which are not open(1) or inavtice (2)
+ user = session['USER_AUTHORIZED']
+ case_bundle = self._filterBundle(case_bundle, (1, 2))
+ if case_bundle.isEmpty():
+ return self._empty_caselist()
+ session['casebundle'] = case_bundle
+ session.save()
+ return self.exportXML(0)
+
+ if action == 'exportCSV':
+ # Fiter out case which are not open(1) or inavtice (2)
+ user = session['USER_AUTHORIZED']
+ case_bundle = self._filterBundle(case_bundle, (1, 2))
+ if case_bundle.isEmpty():
+ return self._empty_caselist()
+ session['casebundle'] = case_bundle
+ session.save()
+ return self.exportCSV(0)
+
+ if action == 'exportXLS':
+ # Fiter out case which are not open(1) or inavtice (2)
+ user = session['USER_AUTHORIZED']
+ case_bundle = self._filterBundle(case_bundle, (1, 2))
+ if case_bundle.isEmpty():
+ return self._empty_caselist()
+ session['casebundle'] = case_bundle
+ session.save()
+ return self.exportXLS(0)
+
except formencode.Invalid, error:
log.exception(error)
raise
@@ -427,5 +466,86 @@
c.form_errors = error.error_dict or {}
return render('/casebundle/standin.mako')
+ # EXPORT
+ @checkRole(('admin', 'cm'))
+ def exportXML(self, confirmed):
+ confirmed = self._checkBool(confirmed)
+ c.context = "../main.mako"
+ case_bundle = session.get('casebundle')
+ if confirmed == 1:
+ num, export = case_bundle.export()
+ del session['casebundle']
+ return self._downloadXMLExport(export)
+ else:
+ c.dialog_title = DIALOG_CONFIRM_EXPORT
+ c.dialog_text = (DIALOG_CONFIRM_EXPORT_EXPLAINATION
+ % "\n".join(self._buildCaseList(case_bundle)))
+ c.url_yes = "/case_bundle/exportXML/1"
+ c.url_no = "/case_overview/"
+ return render('/casemanagement/dialogs/confirm_export.mako')
+ @checkRole(('admin', 'cm'))
+ def exportXLS(self, confirmed):
+ confirmed = self._checkBool(confirmed)
+ c.context = "../main.mako"
+ case_bundle = session.get('casebundle')
+ if confirmed == 1:
+ num, export = case_bundle.export(type="XLS")
+ del session['casebundle']
+ return self._downloadXLSExport(export)
+ else:
+ c.dialog_title = DIALOG_CONFIRM_EXPORT
+ c.dialog_text = (DIALOG_CONFIRM_EXPORT_EXPLAINATION
+ % "\n".join(self._buildCaseList(case_bundle)))
+ c.url_yes = "/case_bundle/exportXLS/1"
+ c.url_no = "/case_overview/"
+ return render('/casemanagement/dialogs/confirm_export.mako')
+
+ @checkRole(('admin', 'cm'))
+ def exportCSV(self, confirmed):
+ confirmed = self._checkBool(confirmed)
+ c.context = "../main.mako"
+ case_bundle = session.get('casebundle')
+ if confirmed == 1:
+ num, export = case_bundle.export(type="CSV")
+ del session['casebundle']
+ return self._downloadCSVExport(export)
+ else:
+ c.dialog_title = DIALOG_CONFIRM_EXPORT
+ c.dialog_text = (DIALOG_CONFIRM_EXPORT_EXPLAINATION
+ % "\n".join(self._buildCaseList(case_bundle)))
+ c.url_yes = "/case_bundle/exportCSV/1"
+ c.url_no = "/case_overview/"
+ return render('/casemanagement/dialogs/confirm_export.mako')
+
+ def _downloadXMLExport(self, export):
+ data = paste.fileapp.DataApp(
+ export,
+ content_type = 'text/xml',
+ content_disposition = 'attachment; filename="fallakten-export.xml"',
+ content_encoding = 'Latin-1',
+ cache_control = 'must-revalidate',
+ pragma = 'public')
+ return data(request.environ, self.start_response)
+
+ def _downloadXLSExport(self, export):
+ data = paste.fileapp.DataApp(
+ export,
+ content_type = 'text/msexcel',
+ content_disposition = 'attachment; filename="fallakten-export.xls"',
+ content_encoding = 'Latin-1',
+ cache_control = 'must-revalidate',
+ pragma = 'public')
+ return data(request.environ, self.start_response)
+
+ def _downloadCSVExport(self, export):
+ data = paste.fileapp.DataApp(
+ export,
+ content_type = 'text/csv',
+ content_disposition = 'attachment; filename="fallakten-export.csv"',
+ content_encoding = 'Latin-1',
+ cache_control = 'must-revalidate',
+ pragma = 'public')
+ return data(request.environ, self.start_response)
+
# vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8:
More information about the Mpuls-commits
mailing list