[Mpuls-commits] r2037 - wasko/branches/2.0/jmdweb/controllers
scm-commit@wald.intevation.org
scm-commit at wald.intevation.org
Fri Mar 19 14:03:29 CET 2010
Author: torsten
Date: 2010-03-19 14:03:28 +0100 (Fri, 19 Mar 2010)
New Revision: 2037
Modified:
wasko/branches/2.0/jmdweb/controllers/case_overview.py
Log:
* jmdweb/controllers/case_overview.py (CaseOverviewController):
Deleted obsolete code. The code was either moved to mpulsbase or is
not used in jmd yet (xml-import xml-export e.g)
Modified: wasko/branches/2.0/jmdweb/controllers/case_overview.py
===================================================================
--- wasko/branches/2.0/jmdweb/controllers/case_overview.py 2010-03-19 11:46:07 UTC (rev 2036)
+++ wasko/branches/2.0/jmdweb/controllers/case_overview.py 2010-03-19 13:03:28 UTC (rev 2037)
@@ -28,161 +28,13 @@
# Torsten Irländer <torsten.irlaender at intevation.de>
#
-import re
import logging
-from cgi import escape
-import formencode
-import paste
-from paste.httpexceptions import HTTPNotFound
+from mpulsweb.controllers.case_overview import CaseOverviewController as \
+ CaseBaseOverviewController, get_sort
-from mpulsweb.lib.base import c, h, render, request, session
-import mpulsweb.lib.helper.filters as F
-from mpulsweb.lib.security import checkRole
-from mpulsweb.lib.validators import BundleActionForm, \
- SetBundleEditorForm, SetBundleStandinForm
-from mpulsweb.model.user import UserListObject, UserObject, UserGroupList
-from mpulsweb.model.case import MpulsCaseOverview
-
-from mpulsweb.controllers.case_overview import CaseOverviewController \
- as CaseBaseOverviewController, FORM_DEFAULTS_ADMIN, \
- FORM_DEFAULTS_CM, get_sort
-
-from jmdweb.lib.validators import CasePartSelectionForm
-from jmdweb.lib.search import INCONSISTENCY_CHECK_AFTER
-from jmdweb.lib.exportselection import CasePartsSelection
-
-from jmdweb.model.case import CaseBundle
-
log = logging.getLogger(__name__)
-DIALOG_EMPTY_SELECTION = u'''Keine Fallakten ausgewählt.'''
-DIALOG_EMPTY_SELECTION_EXPLAINATION = u'''\
-Sie haben keine Fallakten ausgewählt für die Sie die gewählte Aktion
-ausführen können. Bitte klicken Sie auf "OK", um zur Fallaktenübersicht
-zu gelangen und dort Fallakten auszuwählen.'''
-DIALOG_CONFIRM_DELETE = u'''Fallakten löschen?'''
-DIALOG_CONFIRM_EXPLAINATION = u'''\
-Wollen Sie wirklich die folgenden Fallakten löschen?%s'''
-
-DIALOG_CONFIRM_ANONYMIZE = u'''Fallakten anonymisieren?'''
-DIALOG_CONFIRM_ANONYMIZE_EXPLAINATION = u'''\
-Wollen Sie wirklich die folgenden Fallakten anonymisieren und die
-personenbzogenen Daten unwiederbringlich verlieren? Die Fallakten steht
-danach nicht mehr zur Bearbeitung zur Verfügung. Die anonymisierte
-Fallakte werden weiterhin in der Auswertung berücksichtigt werden.%s'''
-DIALOG_CONFIRM_MARKANONYMIZE = u'''Fallakten zur Anonymisierung freigeben?'''
-DIALOG_CONFIRM_MARKANONYMIZE_EXPLAINATION = u'''\
-Wollen Sie wirklich die folgenden Fallakten zum Anonymisieren freigeben?
-Die Fallakten stehen Ihnen danach nicht mehr zur Bearbeitung zur
-Verfügung und werden der Administration zur Anonymisierung vorgelegt.%s'''
-
-DIALOG_CONFIRM_RESTORE = u'''Fallakten wiederherstellen?'''
-DIALOG_CONFIRM_RESTORE_EXPLAINATION = u'''\
-Wollen Sie wirklich die folgenden Fallakten wiederherstellen? Die
-Fallakten stehen danach wieder zur Bearbeitung zur Verfügung.%s'''
-
-DIALOG_CONFIRM_SETEDITOR = u"""Bearbeitung übertragen!"""
-SETEDITOR_NOTIFICATION_SUCCESS = u"""\
-Es wurden %s Fallakten erfolgreich an %s %s übertragen. Bitte klicken
-Sie auf "OK", um fortzufahren."""
-SETEDITOR_FAILED_HEADER = u"""Fallakten nicht übertragen!"""
-SETEDITOR_FAILED_TEXT = u"""\
-Bei dem Übertragen der Fallakten ist eine Fehler aufgetreten. Bitte
-klicken Sie auf "OK", um fortzufahren."""
-
-DIALOG_CONFIRM_SETSTANDIN = u"""Vertretung zugewiesen!"""
-SETSTANDIN_NOTIFICATION_SUCCESS = u"""\
-Es wurden für %s Fallakten erfolgreich die Vertretung zugewiesen. Bitte
-klicken Sie auf "OK", um fortzufahren."""
-SETSTANDIN_NOTIFICATION_ERROR_HEADER = u"""Keine Fallakte zugewiesen!"""
-SETSTANDIN_NOTIFICATION_ERROR = u"""\
-Bei dem Zuweisen der Vertretung für die Fallakten ist ein Fehler
-aufgetreten. Bitte klicken Sie auf "OK", um fortzufahren."""
-
-EXPORT_SUCCESS_XLS = u'''Export erfolgreich - XLS-Datei erstellt!'''
-EXPORT_SUCCESS_XLS_EXPLAINATION = u'''\
-Die Fallakten wurden erfolgreich als XLS-Datei exportiert und stehen zum
-herunterladen bereit.'''
-
-EXPORT_SUCCESS_XML = u'''Export erfolgreich - XML-Datei erstellt!'''
-EXPORT_SUCCESS_XML_EXPLAINATION = u'''\
-Die Fallakten wurden erfolgreich als XML-Datei exportiert und stehen zum
-herunterladen bereit.'''
-
-EXPORT_SUCCESS = u'''Export erfolgreich - CSV-Datei erstellt!'''
-EXPORT_SUCCESS_EXPLAINATION = u'''\
-Die Fallakten wurden erfolgreich als CSV-Datei exportiert und stehen zum
-herunterladen bereit.'''
-
-EXPORT_ERROR = u'''Es ist ein Fehler aufgetreten'''
-EXPORT_ERROR_EXPLAINATION = u'''\
-Bei dem Exportieren der Fallakten ist ein Fehler aufgetreten. Klicken
-Sie auf "OK", um zur Einrichtungenübersicht zu gelangen.'''
-
-BUNDLE_NOTIFICATION_EMPTYLIST_HEADER = u"""\
-Keine gültigen Fälle in der Auswahl!"""
-BUNDLE_NOTIFICATION_EMPTYLIST = u"""\
-Die gewünschte Aktion kann für keine der in der Auswahl befindlichen
-Fallakten durchgeführt werden. Vergewissern Sie sich, dass sich die
-Fallakten in einem Zustand befinden, aus dem Sie die Aktion ausführen
-können."""
-
-BUNDLE_NOTIFICATION_NOACTION_HEADER = u"""\
-Keine Aktion für die Auswahl angegeben!"""
-BUNDLE_NOTIFICATION_NOACTION = u"""\
-Sie haben keine Aktion für die Auswahl angegeben. Bitte klicken Sie auf
-OK, um zur Fallaktenübersicht zu gelangen und dort eine Aktion aus dem
-Auswahlfeld auszuwählen."""
-MARKANONYMIZE_SUCCESS_HEADER = u"""\
-Fallakte wurde zur Anonymisierung freigegeben!"""
-MARKANONYMIZE_SUCCESS_TEXT = u"""\
-Es wurden %s Fallakten zur Anonymisierung freigegeben. Sie liegen der
-Administration zur endgültigen Anonymisierung vor. Bitte klicken Sie auf "Ok",
-um fortzufahren."""
-MARKANONYMIZE_NOTIFICATION_ERROR = u"""\
-Bei dem Freigeben zur Anonymisieren der Fallakten ist ein Fehler
-aufgetreten. Bitte klicken Sie auf "OK", um fortzufahren."""
-ANONYMIZE_SUCCESS_HEADER = u"""Fallakten anonymisiert!"""
-ANONYMIZE_SUCCESS_TEXT = u"""\
-Es wurden %s Fallakten erfolgreich anonymisiert. Bitte klicken Sie auf "Ok",
-um fortzufahren."""
-ANONYMIZE_NOTIFICATION_ERROR = u"""\
-Bei dem Anonymisieren der Fallakten ist ein Fehler aufgetreten. Bitte
-klicken Sie auf "OK", um fortzufahren."""
-DELETE_SUCCESS_ADMIN_HEADER = u"""Fallakten gelöscht!"""
-DELETE_SUCCESS_ADMIN_TEXT = u"""\
-Es wurden %s Fallakten erfolgreich gelöscht. Bitte klicken Sie auf "OK",
-um fortzufahren."""
-DELETE_NOTIFICATION_ERROR = u"""\
-Bei dem Löschen der Fallakten ist ein Fehler aufgetreten. Bitte klicken
-Sie auf "OK", um fortzufahren."""
-MARKDELETE_SUCCESS_HEADER = u"""Fallakten gelöscht!"""
-MARKDELETE_SUCCESS_TEXT = u"""\
-Es wurden %s Fallakten erfolgreich zum Löschen freigegeben. Bitte
-klicken Sie auf "OK", um fortzufahren."""
-MARKDELETE_NOTIFICATION_ERROR = u"""\
-Bei dem Freigeben zum Löschen der Fallakten ist ein Fehler
-aufgetreten. Bitte klicken Sie auf "OK", um fortzufahren."""
-
-RESTORE_SUCCESS_HEADER = u"""Fallakten wiederhergestellt!"""
-RESTORE_SUCCESS_TEXT = u"""\
-Es wurden %s Fallakten erfolgreich wiederhergestellt. Bitte klicken Sie
-auf "OK", um fortzufahren."""
-RESTORE_NOTIFICATION_ERROR = u"""\
-Bei dem Wiederherstellen der Fallakten ist ein Fehler aufgetreten. Bitte
-klicken Sie auf "OK", um fortzufahren."""
-SELECT_PARTS_FOR_EXPORT = u"\
-Welche Bereiche der Fallakte(n) sollen exportiert werden?"
-
-CHECK_SUCCESS=u"""Fallakten überprüft!"""
-CHECK_SUCCESS_EXPLAINATION=u"""\
-Die Fallakten wurde erfolgreich auf ihre Validität überprüft."""
-CHECK_ERROR=u"""Es ist ein Fehler aufgetreten"""
-CHECK_ERROR_EXPLAINATION=u"""\
-Bei dem Überprüfen der Validität ist einer Fehler aufgetreten. Klicken
-Sie auf 'OK', um fortzufahren."""
-
class CaseOverviewController(CaseBaseOverviewController):
def parseSortOptions(self, options=None):
@@ -205,697 +57,4 @@
search_options.append('sort_order:asc')
return search_options
- #def parseSearchOptions(self, options=None):
- # search_options = []
- # user = session['USER_AUTHORIZED']
- # if options.get('editor', '-1') != '-1':
- # search_options.append('editor:%s' % options.get('editor'))
- # if options.get('show_own') == '1':
- # search_options.append('own:%s' % user.id)
- # if options.get('show_other') == '1':
- # search_options.append('standin:%s' % user.id)
- # if options.get('show_open') == '1':
- # search_options.append('state:%s' % 1)
- # search_options.append('state:%s' % 2)
- # if options.get('show_closed') == '1':
- # search_options.append('state:%s' % 2)
- # if options.get('show_markdelete') == '1':
- # search_options.append('state:%s' % 3)
- # if options.get('show_markanonymize') == '1':
- # search_options.append('state:%s' % 4)
- # if options.get('show_anonymized') == '1':
- # search_options.append('state:%s' % 5)
- # # For cm users show cases which are marked for anon too
- # if h.hasRole(['cm_ka']):
- # search_options.append('state:%s' % 4)
- # if options.get('gender', '-2') != '-2':
- # search_options.append('gender:%s' % options.get('gender'))
- # if options.get('branch'):
- # search_options.append('branch:%s' % options.get('branch'))
- # if options.get('search_str'):
- # search_options.append(options.get('search_str'))
-
- # #Migration
- # if options.get('migration', '-2') != '-2':
- # search_options.append('migration:%s' % options.get('migration'))
-
- # #cm-states
- # cm_state = options.get('cm_state')
- # phases = [] # default
- # if cm_state:
- # if cm_state == 'none':
- # phases = []
- # if cm_state == 'clearing':
- # phases = [0,1]
- # if cm_state == 'active':
- # phases = [2]
- # if cm_state == 'finished':
- # phases = [3,4,5]
- # if cm_state == 'all':
- # phases = [-1,0,1,2,3,4,5]
- # phases = '%s' % ";".join("phase:%s" % p for p in phases)
- # if phases:
- # search_options.append(phases)
-
- # #check build time_interval
- # year = options.get('year')
- # quarter = options.get('quarter')
- # if year != '-1' and year:
- # q_start = "01-01"
- # q_end = "12-31"
- # if quarter == '1':
- # q_end = "03-31"
- # if quarter == '2':
- # q_start = "04-01"
- # q_end = "06-30"
- # if quarter == '3':
- # q_start = "07-01"
- # q_end = "09-30"
- # if quarter == '4':
- # q_start = "10-01"
-
- # search_options.append("interval_start_date:%s" % "-".join([year,
- # q_start]))
- # search_options.append("interval_end_date:%s" % "-".join([year, q_end]))
-
- # return search_options
-
- @checkRole(('admin_ka', 'cm_ka', 'pt_dlr'))
- def bundleAction(self):
- validator = BundleActionForm()
- c.context = "../main.mako"
- c.url_ok = "/case_overview"
- try:
- data = formencode.variabledecode.variable_decode(request.params)
- session['CASE_OVERVIEW_SELECTION'] = data
- session.save()
- form_result = validator.to_python(data)
- action = form_result.get('action')
- c.current_user = session['USER_AUTHORIZED']
- if form_result.get('all_cases') > 0:
- # Narf! Load ids of all cases with the last search
- # option again as they are not included in the submitted
- # data.
-
- # If the user is admin then he should see only cases
- # which are marked for deletion or anonymisation
- if c.current_user.isAdmin():
- FORM_DEFAULTS = FORM_DEFAULTS_ADMIN
- else:
- FORM_DEFAULTS = FORM_DEFAULTS_CM
- search_options = (session.get('CASE_OVERVIEW_SEARCHOPTIONS')
- or FORM_DEFAULTS)
- search_str = ";".join(self.parseSearchOptions(search_options))
- case_bundle = CaseBundle([case.id for case in
- MpulsCaseOverview().search(search_str)])
- else:
- case_bundle = CaseBundle(form_result.get('case_id', []))
-
- if case_bundle.isEmpty():
- c.notification_for = DIALOG_EMPTY_SELECTION
- c.notification_text = DIALOG_EMPTY_SELECTION_EXPLAINATION
- return render('/casemanagement/dialogs/bundle_noselection.mako')
- if action == 'no_action':
- c.notification_for = BUNDLE_NOTIFICATION_NOACTION_HEADER
- c.notification_text = BUNDLE_NOTIFICATION_NOACTION
- return render('/casemanagement/dialogs/bundle_noselection.mako')
-
- group_list = UserGroupList()
- user_list = UserListObject()
- group_filter = [u.gid for u in user_list.getAdminList()]
- user_filter = [u.id for u in user_list.getAdminList()]
- group_filter.append(c.current_user.gid)
- user_filter.append(c.current_user.id)
- c.group_list = group_list.getGroupList(group_filter)
- c.user_list = user_list.getUserList(user_filter)
-
- if action == 'delete':
- # Filter out cases which aren't marked for deletion (3),
- # or are anonymized (5)
- case_bundle = self._filterBundle(case_bundle, (3,5))
- if case_bundle.isEmpty():
- return self._emptyListError()
- session['casebundle'] = case_bundle
- session.save()
- return self.delete(0)
-
- if action == 'anonymize':
- # Filter out cases which aren't marked for anonymization (4)
- case_bundle = self._filterBundle(case_bundle, [4],
- filter_inconsistent=True)
- if case_bundle.isEmpty():
- return self._emptyListError()
- session['casebundle'] = case_bundle
- session.save()
- return self.anonymize(0)
-
- if action == 'restore':
- # Filter out cases which aren't marked for anonymization (4),
- # or marked for deletion (3)
- case_bundle = self._filterBundle(case_bundle, (3, 4))
- if case_bundle.isEmpty():
- return self._emptyListError()
- session['casebundle'] = case_bundle
- session.save()
- return self.restore(0)
-
- if action == 'markdelete':
- # Fiter out case which are not open(1) or inactive (2)
- case_bundle = self._filterBundle(case_bundle, (1, 2))
- if case_bundle.isEmpty():
- return self._emptyListError()
- session['casebundle'] = case_bundle
- session.save()
- return self.markDelete(0)
-
- if action == 'markanonymize':
- # Fiter out case which are not open(1) or inactive (2)
- case_bundle = self._filterBundle(case_bundle, (1, 2),
- filter_inconsistent=True)
- if case_bundle.isEmpty():
- return self._emptyListError()
- session['casebundle'] = case_bundle
- session.save()
- return self.markAnonymize(0)
-
- elif action == 'stand-in':
- # filter out cases where the user is not the editor and
- # therefor is not allowed to set the standin.
- filtered = []
- for case in case_bundle.getCases():
- if (case.getEditor().id != c.current_user.id
- and not c.current_user.isAdmin()):
- filtered.append(case.id)
-
- # Fiter out case which are not open(1) or inavtice (2)
- case_bundle = self._filterBundle(case_bundle, (1, 2), filtered)
- if case_bundle.isEmpty():
- return self._emptyListError()
- c.case_list = case_bundle.getCases()
- session['casebundle'] = case_bundle
- session.save()
- return render('/casemanagement/bundle_standin.mako')
-
- elif action == 'transfer':
- # Fiter out case which are not open(1) or inavtice (2)
- case_bundle = self._filterBundle(case_bundle, (1, 2))
- if case_bundle.isEmpty():
- return self._emptyListError()
- c.case_list = case_bundle.getCases()
- session['casebundle'] = case_bundle
- session.save()
- return render('/casemanagement/bundle_editor.mako')
-
- elif action == 'exportCSV':
- # Fiter out case which are not open(1) or inavtice (2)
- if case_bundle.isEmpty():
- return self._emptyListError()
- session['casebundle'] = case_bundle
- session.save()
- return self.exportCSV(1)
-
- elif action == 'exportXLS':
- # Fiter out case which are not open(1) or inavtice (2)
- if case_bundle.isEmpty():
- return self._emptyListError()
- session['casebundle'] = case_bundle
- session.save()
- return self.exportXLS(1)
-
- elif action == 'exportXML':
- # Fiter out case which are not open(1) or inavtice (2)
- if case_bundle.isEmpty():
- return self._emptyListError()
- session['casebundle'] = case_bundle
- session.save()
- return self.exportXML(1)
-
- else:
- raise HTTPNotFound()
-
- except formencode.Invalid, error:
- c.form_result = error.value
- c.form_errors = error.error_dict or {}
- form = render('/casemanagement/overview.mako')
- return htmlfill.render(unicode(form, 'utf-8'), c.form_result,
- c.form_errors, auto_insert_errors=False)
- return self.overview()
-
- def _filterBundle(self, case_bundle, allowedstates, filtered_cases=None,
- filter_inconsistent=False):
- """Returns a filtered CaseBundle. Filtering can be done on
- states and on inconsistent cases (not all required fields are
- filled for current phase)
- """
- filtered = []
- for case in case_bundle.getCases(filtered_cases):
- state = case.getState()
- if (filter_inconsistent
- and ((not state.phasesAreConsistent()
- or not state.phasesAreCompleted())
- and case.isYoungerThan(INCONSISTENCY_CHECK_AFTER))):
- continue
- if state.getState() in allowedstates:
- filtered.append(case.id)
- case_bundle = CaseBundle(filtered)
- return case_bundle
-
- def _emptyListError(self):
- c.url_ok = "/case_overview"
- c.notification_for = BUNDLE_NOTIFICATION_EMPTYLIST_HEADER
- c.notification_text = BUNDLE_NOTIFICATION_EMPTYLIST
- return render('/casemanagement/dialogs/bundle_noselection.mako')
-
- def _buildCaseList(self, bundle):
- list = ["<ul>"]
- for case in bundle.getCases():
- list.append("<li>%s, %s</li>" % (escape(F.NA(case.first_name)),
- escape(F.NA(case.last_name))))
- list.append("</ul>")
- return list
-
- @checkRole(('admin_ka'))
- def setEditorAction(self):
- c.context = "../main.mako"
- c.url_ok = "/case_overview"
- c.success_for = DIALOG_CONFIRM_SETEDITOR
- case_bundle = session.get('casebundle')
- validator = SetBundleEditorForm()
- try:
- form_result = validator.to_python(request.params)
- try:
- num = case_bundle.setEditor(form_result.get('editor'))
- user = UserObject(form_result.get('editor'))
- c.success_text = (SETEDITOR_NOTIFICATION_SUCCESS
- % (str(num), user.first_name, user.last_name))
- except StandardError, err:
- c.failed_for = SETEDITOR_FAILED_HEADER
- c.failed_text = SETEDITOR_FAILED_TEXT
- return render ('/casemanagement/dialogs/failed_seteditor.mako')
- del session['casebundle']
- except formencode.Invalid, error:
- c.form_result = error.value
- c.form_errors = error.error_dict or {}
- return render('/casemanagement/bundle_editor.mako')
- return render('/casemanagement/dialogs/notificate_bundle_seteditor.mako')
-
- @checkRole(('admin_ka', 'cm_ka'))
- def setStandinAction(self):
- c.context = "../main.mako"
- c.url_ok = "/case_overview"
- c.success_for = DIALOG_CONFIRM_SETSTANDIN
- case_bundle = session.get('casebundle')
- validator = SetBundleStandinForm()
- try:
- data = formencode.variabledecode.variable_decode(request.params)
- form_result = validator.to_python(data)
- try:
- num = case_bundle.setStandin(form_result.get('standin'))
- c.success_text = SETSTANDIN_NOTIFICATION_SUCCESS % str(num)
- except StandardError, err:
- c.success_for = SETSTANDIN_NOTIFICATION_ERROR_HEADER
- c.success_text = SETSTANDIN_NOTIFICATION_ERROR
- del session['casebundle']
- except formencode.Invalid, error:
- c.form_result = error.value
- c.form_errors = error.error_dict or {}
- return render('/casemanagement/bundle_standin.mako')
- return render('/casemanagement/dialogs/notificate_bundle_setstandin.mako')
-
- @checkRole(('admin_ka'))
- def delete(self, confirmed):
- confirmed = self._checkBool(confirmed)
- c.context = "../main.mako"
- c.url_ok = "/case_overview"
- c.notification_for = DIALOG_CONFIRM_DELETE
- case_bundle = session.get('casebundle')
- if confirmed == 1:
- try:
- num = case_bundle.delete()
- c.success_for = DELETE_SUCCESS_ADMIN_HEADER
- c.success_text = DELETE_SUCCESS_ADMIN_TEXT % str(num)
- return render('/casemanagement/dialogs/success_delete_admin.mako')
- except StandardError, err:
- c.notification_text = DELETE_NOTIFICATION_ERROR
- del session['casebundle']
- else:
- c.context = "../main.mako"
- c.confirm_for = DIALOG_CONFIRM_DELETE
- c.question = (DIALOG_CONFIRM_EXPLAINATION
- % "\n".join(self._buildCaseList(case_bundle)))
- c.url_yes = "/case_overview/delete/1"
- c.url_no = "/case_overview/"
- return render('/casemanagement/dialogs/confirm.mako')
- return render('/casemanagement/dialogs/notificate_bundle_delete.mako')
-
- @checkRole(('admin_ka'))
- def anonymize(self, confirmed):
- confirmed = self._checkBool(confirmed)
- c.context = "../main.mako"
- c.url_ok = "/case_overview"
- c.notification_for = DIALOG_CONFIRM_ANONYMIZE
- case_bundle = session.get('casebundle')
- if confirmed == 1:
- try:
- num = case_bundle.anonymize()
- c.success_for = ANONYMIZE_SUCCESS_HEADER
- c.success_text = ANONYMIZE_SUCCESS_TEXT % str(num)
- return render ('/casemanagement/dialogs/success_bundle_anonymize.mako')
- except StandardError, err:
- c.notification_text = ANONYMIZE_NOTIFICATION_ERROR
- del session['casebundle']
- else:
- c.context = "../main.mako"
- c.confirm_for = DIALOG_CONFIRM_ANONYMIZE
- c.question = (DIALOG_CONFIRM_ANONYMIZE_EXPLAINATION
- % "\n".join(self._buildCaseList(case_bundle)))
- c.url_yes = "/case_overview/anonymize/1"
- c.url_no = "/case_overview/"
- return render('/casemanagement/dialogs/confirm_bundle_anonymize.mako')
- return render('/casemanagement/dialogs/notificate_bundle_delete.mako')
-
- @checkRole(('cm_ka'))
- def markDelete(self, confirmed):
- confirmed = self._checkBool(confirmed)
- c.context = "../main.mako"
- c.url_ok = "/case_overview"
- c.notification_for = DIALOG_CONFIRM_DELETE
- case_bundle = session.get('casebundle')
- if confirmed == 1:
- try:
- num = case_bundle.markDelete()
- c.success_for = MARKDELETE_SUCCESS_HEADER
- c.success_text = MARKDELETE_SUCCESS_TEXT % str(num)
- return render ('/casemanagement/dialogs/success_markdelete.mako')
- except StandardError, err:
- c.notification_text = MARKDELETE_NOTIFICATION_ERROR
- del session['casebundle']
- else:
- c.context = "../main.mako"
- c.confirm_for = DIALOG_CONFIRM_DELETE
- c.question = (DIALOG_CONFIRM_EXPLAINATION
- % "\n".join(self._buildCaseList(case_bundle)))
- c.url_yes = "/case_overview/markDelete/1"
- c.url_no = "/case_overview/"
- return render('/casemanagement/dialogs/confirm.mako')
- return render('/casemanagement/dialogs/notificate_bundle_delete.mako')
-
- @checkRole(('cm_ka'))
- def markAnonymize(self, confirmed):
- confirmed = self._checkBool(confirmed)
- c.context = "../main.mako"
- c.url_ok = "/case_overview"
- c.notification_for = DIALOG_CONFIRM_MARKANONYMIZE
- case_bundle = session.get('casebundle')
- if confirmed == 1:
- try:
- num = case_bundle.markAnonymize()
- c.success_for = MARKANONYMIZE_SUCCESS_HEADER
- c.success_text = MARKANONYMIZE_SUCCESS_TEXT % str(num)
- return render ('/casemanagement/dialogs/success_bundle_anonymize.mako')
- except StandardError, err:
- print err
- c.notification_text = MARKANONYMIZE_NOTIFICATION_ERROR
- del session['casebundle']
- else:
- c.context = "../main.mako"
- c.confirm_for = DIALOG_CONFIRM_MARKANONYMIZE
- c.question = (DIALOG_CONFIRM_MARKANONYMIZE_EXPLAINATION
- % "\n".join(self._buildCaseList(case_bundle)))
- c.url_yes = "/case_overview/markAnonymize/1"
- c.url_no = "/case_overview/"
- return render('/casemanagement/dialogs/confirm_bundle_anonymize.mako')
- return render('/casemanagement/dialogs/notificate_bundle_delete.mako')
-
- @checkRole(('admin_ka'))
- def restore(self, confirmed):
- confirmed = self._checkBool(confirmed)
- c.context = "../main.mako"
- c.url_ok = "/case_overview"
- c.notification_for = DIALOG_CONFIRM_RESTORE
- case_bundle = session.get('casebundle')
- if confirmed == 1:
- try:
- num = case_bundle.restore()
- c.success_for = RESTORE_SUCCESS_HEADER
- c.success_text = RESTORE_SUCCESS_TEXT % str(num)
- return render ('/casemanagement/dialogs/success_restore.mako')
- except StandardError, err:
- print err
- c.notification_text = RESTORE_NOTIFICATION_ERROR
- del session['casebundle']
- else:
- c.context = "../main.mako"
- c.confirm_for = DIALOG_CONFIRM_RESTORE
- c.question = (DIALOG_CONFIRM_RESTORE_EXPLAINATION
- % "\n".join(self._buildCaseList(case_bundle)))
- c.url_yes = "/case_overview/restore/1"
- c.url_no = "/case_overview/"
- return render('/casemanagement/dialogs/confirm_restore.mako')
- return render('/casemanagement/dialogs/notificate_bundle_restore.mako')
-
- @checkRole(('cm_ka', 'admin_ka'))
- def checkValidity(self, confirmed):
- confirmed = self._checkBool(confirmed)
- case_bundle = session.get('casebundle')
- try:
- case_bundle.checkValidity()
- c.success_for = CHECK_SUCCESS
- c.success_text = CHECK_SUCCESS_EXPLAINATION
- return render('/casemanagement/dialogs/success_checkvalidity.mako')
- except StandardError, err:
- c.failed_for = CHECK_ERROR
- c.failed_test = CHECK_ERROR_EXPLAINATION
- c.url_ok = "/agency_overview/"
- return render('/casemanagement/dialogs/failed_checkvalidity.mako')
-
- @checkRole(('cm_ka', 'admin_ka'))
- def exportCSV(self, confirmed):
- confirmed = self._checkBool(confirmed)
- case_bundle = session.get('casebundle')
- c.context = "../main.mako"
- try:
- c.success_for = EXPORT_SUCCESS
- c.success_text = EXPORT_SUCCESS_EXPLAINATION
- return self.downloadCSV()
- except StandardError, err:
- c.failed_for = EXPORT_ERROR
- c.failed_test = EXPORT_ERROR_EXPLAINATION
- c.url_ok = "/agency_overview/"
- return render('/casemanagement/dialogs/failed_export_agency.mako')
-
- @checkRole(('cm_ka', 'admin_ka'))
- def exportXML(self, confirmed):
- confirmed = self._checkBool(confirmed)
- case_bundle = session.get('casebundle')
- c.context = "../main.mako"
- try:
- c.success_for = EXPORT_SUCCESS_XML
- c.success_text = EXPORT_SUCCESS_XML_EXPLAINATION
- return self.downloadXML()
- except StandardError, err:
- c.failed_for = EXPORT_ERROR
- c.failed_test = EXPORT_ERROR_EXPLAINATION
- c.url_ok = "/agency_overview/"
- return render('/casemanagement/dialogs/failed_export_agency.mako')
-
- @checkRole(('cm_ka', 'admin_ka'))
- def exportXLS(self, confirmed):
- confirmed = self._checkBool(confirmed)
- case_bundle = session.get('casebundle')
- c.context = "../main.mako"
- try:
- c.success_for = EXPORT_SUCCESS_XLS
- c.success_text = EXPORT_SUCCESS_XLS_EXPLAINATION
- return self.downloadXLS()
- except StandardError, err:
- c.failed_for = EXPORT_ERROR
- c.failed_test = EXPORT_ERROR_EXPLAINATION
- c.url_ok = "/agency_overview/"
- return render('/casemanagement/dialogs/failed_export_agency.mako')
-
- @checkRole(('cm_ka', 'admin_ka'))
- def downloadCSV(self):
- selection_checker = self.__getSelectionChecker()
- c.is_all_selected = selection_checker.isAllSelected()
- c.download_link = h.url_for(action="downloadCSVAction")
- c.selection_link = h.url_for(action="selectCSVParts")
- c.overview_link = h.url_for(action="overview")
- return render('casemanagement/downloadCSV.mako')
-
- @checkRole(('cm_ka', 'admin_ka'))
- def selectCSVParts(self):
- selection_checker = self.__getSelectionChecker()
- c.selection_question = SELECT_PARTS_FOR_EXPORT
- c.store_action = h.url_for(action="storeSelectedCSVParts")
- c.back_url = h.url_for(controller='/case_overview', action='exportCSV',
- confirmed=1)
- c.back_title = "CSV Export"
- c.selectLogbook = False
- c.selectDocuments = False
- page = render('casemanagement/selectParts.mako')
- return formencode.htmlfill.render(unicode(page, 'utf-8'),
- defaults=selection_checker.selections)
-
- def __getSelectionChecker(self):
-
- selection_checker = session.get('selected_export_parts')
- if not selection_checker:
- selection_checker = CasePartsSelection()
- session['selected_export_parts'] = selection_checker
- session.save()
-
- return selection_checker
-
- @checkRole(('cm_ka', 'admin_ka'))
- def downloadXML(self):
- selection_checker = self.__getSelectionChecker()
- c.is_all_selected = selection_checker.isAllSelected()
- c.selection_link = h.url_for(action="selectXMLParts")
- c.download_link = h.url_for(action="downloadXMLAction")
- c.overview_link = h.url_for(action="overview")
- return render('casemanagement/downloadXML.mako')
-
- @checkRole(('cm_ka', 'admin_ka'))
- def selectXMLParts(self):
- selection_checker = self.__getSelectionChecker()
- c.selection_question = SELECT_PARTS_FOR_EXPORT
- c.store_action = h.url_for(action="storeSelectedXMLParts")
- c.back_url = h.url_for(controller='/case_overview', action='exportXML',
- confirmed=1)
- c.back_title = "XML Export"
- c.selectLogbook = True
- c.selectDocuments = True
- page = render('casemanagement/selectParts.mako')
- return formencode.htmlfill.render(unicode(page, 'utf-8'),
- defaults=selection_checker.selections)
-
- @checkRole(('cm_ka', 'admin_ka'))
- def selectXLSParts(self):
- selection_checker = self.__getSelectionChecker()
- c.selection_question = SELECT_PARTS_FOR_EXPORT
- c.store_action = h.url_for(action="storeSelectedXLSParts")
- c.back_url = h.url_for(controller='/case_overview', action='exportXLS',
- confirmed=1)
- c.back_title = "XLS Export"
- c.selectLogbook = False
- c.selectDocuments = False
- page = render('casemanagement/selectParts.mako')
- return formencode.htmlfill.render(unicode(page, 'utf-8'),
- defaults=selection_checker.selections)
-
- def __store_selection(self, params):
- selection_checker = self.__getSelectionChecker()
- new_values = {}
-
- for k in selection_checker.selections.iterkeys():
- try:
- new_values[k] = params[k]
- except KeyError:
- new_values[k] = 0
-
- for key, value in new_values.iteritems():
- selection_checker.setChecked(key, value)
-
- session['selected_export_parts'] = selection_checker
- session.save()
-
- @checkRole(('cm_ka', 'admin_ka'))
- def storeSelectedXMLParts(self):
- validator = CasePartSelectionForm()
- try:
- self.__store_selection(validator.to_python(request.params))
- except formencode.Invalid, error:
- return selectXMLParts()
- return self.exportXML(1)
-
- @checkRole(('cm_ka', 'admin_ka'))
- def storeSelectedXLSParts(self):
- validator = CasePartSelectionForm()
- try:
- self.__store_selection(validator.to_python(request.params))
- except formencode.Invalid, error:
- return selectXLSParts()
- return self.exportXLS(1)
-
- @checkRole(('cm_ka', 'admin_ka'))
- def storeSelectedCSVParts(self):
- validator = CasePartSelectionForm()
- try:
- self.__store_selection(validator.to_python(request.params))
- except formencode.Invalid, error:
- return selectCSVParts()
- return self.exportCSV(1)
-
- @checkRole(('cm_ka', 'admin_ka'))
- def downloadXLS(self):
- selection_checker = self.__getSelectionChecker()
- c.is_all_selected = selection_checker.isAllSelected()
- c.selection_link = h.url_for(action="selectXLSParts")
- c.download_link = h.url_for(action="downloadXLSAction")
- c.overview_link = h.url_for(action="overview")
- return render('casemanagement/downloadXLS.mako')
-
- @checkRole(('cm_ka', 'admin_ka'))
- def downloadCSVAction(self):
- case_bundle = session.get('casebundle')
- case_ids = case_bundle.listDatasetIds()
- anonymize = request.params.get('anonymize') and True or False
- try:
- if case_ids:
- case_bundle = CaseBundle(case_ids)
- selection_checker = self.__getSelectionChecker()
- csv = case_bundle.exportAsCSV(selection_checker, anonymize)
- data = paste.fileapp.DataApp(
- csv,
- 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)
- except:
- return render('/tests/trace.mako')
-
- @checkRole(('cm_ka', 'admin_ka'))
- def downloadXMLAction(self):
- case_bundle = session.get('casebundle')
- case_ids = case_bundle.listDatasetIds()
- anonymize = request.params.get('anonymize') and True or False
- try:
- if case_ids:
- case_bundle = CaseBundle(case_ids)
- selection_checker = self.__getSelectionChecker()
- xml = case_bundle.exportAsXML(selection_checker, anonymize)
- data = paste.fileapp.DataApp(
- xml,
- content_type = 'application/xml',
- content_encoding = 'UTF-8',
- cache_control = 'must-revalidate',
- content_disposition = 'attachment; filename="fallakten-export.xml"',
- pragma = 'public')
- return data(request.environ, self.start_response)
- except:
- return render('/tests/trace.mako')
-
- @checkRole(('cm_ka', 'admin_ka'))
- def downloadXLSAction(self):
- case_bundle = session.get('casebundle')
- case_ids = case_bundle.listDatasetIds()
- anonymize = request.params.get('anonymize') and True or False
- try:
- if case_ids:
- case_bundle = CaseBundle(case_ids)
- selection_checker = self.__getSelectionChecker()
- xls = case_bundle.exportAsXLS(selection_checker, anonymize)
- data = paste.fileapp.DataApp(
- xls,
- content_type = 'application/msexcel',
- content_disposition = 'attachment; filename="fallakten-export.xls"',
- cache_control = 'must-revalidate',
- pragma = 'public')
- return data(request.environ, self.start_response)
- except:
- return render('/tests/trace.mako')
-
# vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8:
More information about the Mpuls-commits
mailing list