[Mpuls-commits] r3325 - wasko/trunk/waskoweb/controllers
scm-commit@wald.intevation.org
scm-commit at wald.intevation.org
Tue Aug 3 17:15:54 CEST 2010
Author: torsten
Date: 2010-08-03 17:15:53 +0200 (Tue, 03 Aug 2010)
New Revision: 3325
Modified:
wasko/trunk/waskoweb/controllers/case.py
Log:
* waskoweb/controllers/case.py (CaseController.wiederaufnahmeAction),
waskoweb/controllers/case.py (CaseController.neuaufnahmeAction): New
Actions for "Neuaufnahme" and "Wiederaufnahme".
Modified: wasko/trunk/waskoweb/controllers/case.py
===================================================================
--- wasko/trunk/waskoweb/controllers/case.py 2010-08-03 15:13:33 UTC (rev 3324)
+++ wasko/trunk/waskoweb/controllers/case.py 2010-08-03 15:15:53 UTC (rev 3325)
@@ -35,6 +35,7 @@
from mpulsweb.lib.base import c, g, render, request, session
from mpulsweb.lib.security import checkRole
+from mpulsweb.lib.helpers import format_date
from mpulsweb.model.case import SessionCase, Agency
from mpulsweb.model.statement import PrivacyStatement
@@ -42,7 +43,8 @@
from mpulsweb.controllers.formularpage import convert2dic
from mpulsweb.controllers.case import CaseController as MpulsCaseController
-from waskoweb.lib.validators import NewCaseForm
+from waskoweb.lib.validators import NewCaseForm, NeuaufnahmeCaseForm, \
+ WiederaufnahmeCaseForm
log = logging.getLogger(__name__)
@@ -71,41 +73,19 @@
form_result = validator.to_python(request.params)
aufnahme_typ = form_result["aufnahme_typ"]
- #if aufnahme_typ in (1, 2):
- # session['signed'] = bool(form_result.get('statement_signed'))
- # session.save()
+ if aufnahme_typ in (1, 2):
+ session['signed'] = bool(form_result.get('statement_signed'))
+ session.save()
- #if aufnahme_typ == 1:
- # # Wiedernahme
- # c.form_errors = {}
- # return render('/casemanagement/wiederaufnahme.mako')
- #if aufnahme_typ == 2:
- # # Neuaufnahme
- # c.form_errors = {}
- # return render('/casemanagement/neuaufnahme.mako')
-
- # 1. Create a new case
- case = g.case_factory.createNew(data=convert2dic({}))
- case._load_formed_instance_tree()
- # Set data
- data = {}
- for k in convert2dic(form_result).keys():
- try:
- item = case.formed_instance.getAllItemsForName(k)[0]
- id = ":".join(item.getIdentifier().split(':')[1:])
- data["%s:%s" % (k,id)] = form_result.get(k)
- except:
- # some values within the formresult can not be found in
- # instance tree. e.g "statement_signed"
- pass
- case.formed_instance.setData(data)
- case.formed_instance.commit()
-
- statement = case.getPrivacyStatement()
- # 3. Do we want to sign the statement?
- if form_result.get('statement_signed'):
- statement.sign()
-
+ if aufnahme_typ == 1:
+ # Wiedernahme
+ c.form_errors = {}
+ return render('/casemanagement/wiederaufnahme.mako')
+ if aufnahme_typ == 2:
+ # Neuaufnahme
+ c.form_errors = {}
+ return render('/casemanagement/neuaufnahme.mako')
+ case = self._createCase(form_result)
except formencode.Invalid, error:
log.debug("Invalid form data: %r", error)
c.form_result = error.value
@@ -114,4 +94,61 @@
return self.select(str(case.id))
+ @checkRole('cm_ka')
+ def neuaufnahmeAction(self):
+ try:
+ session_case = session['case']
+ signed = session['signed']
+ except KeyError:
+ raise HTTPNotFound("case not found")
+
+ # check extra params here!
+ validator = NeuaufnahmeCaseForm()
+ try:
+ form_result = validator.to_python(request.params)
+ form_result.update(session_case.getData())
+ form_result['cm_neuauf_genehm'] = '1'
+ form_result['cm2c'] = '1'
+ form_result['cm_dok_end_art'] = '2'
+ form_result['fn'] = '_NA'
+ case = self._createCase(form_result)
+ return self.select(str(case.id))
+ except formencode.Invalid, error:
+ form = render('/casemanagement/neuaufnahme.mako')
+ return formencode.htmlfill.render(form,
+ defaults = error.value,
+ errors = error.error_dict)
+
+ @checkRole('cm_ka')
+ def wiederaufnahmeAction(self):
+ try:
+ session_case = session['case']
+ signed = session['signed']
+ except KeyError:
+ raise HTTPNotFound("case not found")
+
+ # check extra params here!
+ validator = WiederaufnahmeCaseForm()
+ try:
+ form_result = validator.to_python(request.params)
+ form_result.update(session_case.getData())
+ # convert datefields back to strings:
+ fields = ['cm_dok_datum_beendigung',
+ 'cm_wiederauf_genehm_datum_1',
+ 'cm_wiederauf_datum_bis_1']
+ for k in fields:
+ form_result[k] = format_date(form_result.get(k))
+ form_result['cm_wiederauf_genehm_1'] = '1'
+ form_result['cm2c'] = '1'
+ form_result['fn'] = '_WA'
+ form_result['cm_dok_end_art'] = '1'
+ form_result['datum_cm_start'] = form_result['cm_wiederauf_genehm_datum_1']
+ case = self._createCase(form_result)
+ return self.select(str(case.id))
+ except formencode.Invalid, error:
+ form = render('/casemanagement/wiederaufnahme.mako')
+ return formencode.htmlfill.render(form,
+ defaults = error.value,
+ errors = error.error_dict)
+
# vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8:
More information about the Mpuls-commits
mailing list