[Mpuls-commits] r1138 - wasko/branches/2.0/waskaweb/controllers
scm-commit@wald.intevation.org
scm-commit at wald.intevation.org
Tue Feb 2 15:09:04 CET 2010
Author: torsten
Date: 2010-02-02 15:08:59 +0100 (Tue, 02 Feb 2010)
New Revision: 1138
Modified:
wasko/branches/2.0/waskaweb/controllers/caseappointment.py
Log:
* waskaweb/controllers/caseappointment.py
(CaseappointmentController.newAction): New. Moved from case controller.
Modified: wasko/branches/2.0/waskaweb/controllers/caseappointment.py
===================================================================
--- wasko/branches/2.0/waskaweb/controllers/caseappointment.py 2010-02-02 14:02:49 UTC (rev 1137)
+++ wasko/branches/2.0/waskaweb/controllers/caseappointment.py 2010-02-02 14:08:59 UTC (rev 1138)
@@ -8,7 +8,8 @@
from waskaweb.lib.security import checkRole
from waskaweb.lib.base import BaseController, render
-from waskaweb.lib.helpers import dd_mm_YYYY, HH_MM
+from waskaweb.lib.helpers import url_for, dd_mm_YYYY, HH_MM
+from waskaweb.lib.validators import CreateAppointmentForm
from waskaweb.model.appointment import CaseAppointmentOverview, \
CaseAppointmentFactory, CaseReminderOverview
from waskaweb.controllers.case import checkPrivacyStatement
@@ -52,7 +53,39 @@
return formencode.htmlfill.render(unicode(form, 'utf-8'),
defaults=form_defaults)
+ @checkRole(('cm_ka'))
+ def newAction(self):
+ validator = CreateAppointmentForm()
+ factory = CaseAppointmentFactory()
+ form_errors = {}
+ form_result = {}
+ try:
+ try:
+ form_result = validator.to_python(request.params)
+ # Create appointment
+ appointment = factory.createNew(form_result.get('case_id'))
+ appointment.setData(form_result)
+ appointment.store()
+ c.success_for = CREATE_APPOINT_NOTIFICATION_SUCCESS
+ c.success_text = CREATE_APPOINT_NOTIFICATION_TEXT_SUCCESS
+ c.url_ok = url_for(controller='/caseappointment',
+ action='index',
+ id=appointment.case_id)
+ return render('/casemanagement/dialogs/success_create_appointment.mako')
+ except formencode.Invalid, error:
+ form_result = error.value
+ form_errors = error.error_dict or {}
+ form = render('/casemanagement/newAppointment.mako')
+ return formencode.htmlfill.render(unicode(form, 'utf-8'),
+ defaults=form_result,
+ auto_insert_errors=False,
+ errors=form_errors)
+ except Exception, e:
+ log.exception(e)
+ raise
+
+
@checkRole(('admin_ka', 'cm_ka'))
@checkPrivacyStatement('showAppointment')
def show(self, id, confirmed):
More information about the Mpuls-commits
mailing list