[Mpuls-commits] r1146 - wasko/branches/2.0/waskaweb/controllers
scm-commit@wald.intevation.org
scm-commit at wald.intevation.org
Tue Feb 2 15:43:21 CET 2010
Author: torsten
Date: 2010-02-02 15:43:18 +0100 (Tue, 02 Feb 2010)
New Revision: 1146
Modified:
wasko/branches/2.0/waskaweb/controllers/caseappointment.py
Log:
* waskaweb/controllers/caseappointment.py
(CaseappointmentController.editAction): 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:40:30 UTC (rev 1145)
+++ wasko/branches/2.0/waskaweb/controllers/caseappointment.py 2010-02-02 14:43:18 UTC (rev 1146)
@@ -123,6 +123,63 @@
return render('/casemanagement/showAppointment.mako')
@checkRole(('cm_ka'))
+ @checkRole(('cm_ka'))
+ def edit(self, id):
+ id = self._checkInt(id)
+ factory = CaseAppointmentFactory()
+ app = factory.loadById(id)
+
+ c.form_result = {'start_date': dd_mm_YYYY(app.start_date),
+ 'start_time': HH_MM(app.start_date),
+ 'end_date': dd_mm_YYYY(app.end_date),
+ 'end_time': HH_MM(app.end_date),
+ 'title': app.title,
+ 'id': app.id,
+ 'case_id': app.case_id,
+ 'type': app.type,
+ 'description': app.description}
+
+ c.form_errors = {}
+ c.appointment = app
+ form = render('/casemanagement/editAppointment.mako')
+ return formencode.htmlfill.render(unicode(form, 'utf-8'),
+ defaults=c.form_result,
+ auto_insert_errors=False,
+ errors=c.form_errors)
+
+ @checkRole(('cm_ka'))
+ def editAction(self):
+ validator = CreateAppointmentForm()
+ factory = CaseAppointmentFactory()
+ c.form_errors = {}
+ c.form_result = {}
+ try:
+ try:
+ form_result = validator.to_python(request.params)
+ # Load appointment and set data
+ appointment = factory.loadById(form_result.get('id'))
+ appointment.setData(form_result)
+ appointment.store()
+ c.success_for = EDIT_APPOINT_NOTIFICATION_SUCCESS
+ c.success_text = EDIT_APPOINT_NOTIFICATION_TEXT_SUCCESS
+ c.url_ok = url_for(controller='/caseappointment',
+ action='index',
+ id=appointment.case_id)
+
+ return render('/casemanagement/dialogs/success_edit_appointment.mako')
+ except formencode.Invalid, error:
+ c.form_result = error.value
+ c.form_errors = error.error_dict or {}
+ c.appointment = factory.loadById(c.form_result.get('id'))
+ form = render('/casemanagement/editAppointment.mako')
+ return formencode.htmlfill.render(unicode(form, 'utf-8'),
+ defaults=c.form_result,
+ auto_insert_errors=False,
+ errors=c.form_errors)
+ except Exception, e:
+ log.exception(e)
+ raise
+
def delete(self, id, confirmed='0'):
id = self._checkInt(id)
confirmed = self._checkBool(confirmed)
More information about the Mpuls-commits
mailing list