[Mpuls-commits] r1140 - wasko/branches/2.0/waskaweb/controllers

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Tue Feb 2 15:29:18 CET 2010


Author: torsten
Date: 2010-02-02 15:29:18 +0100 (Tue, 02 Feb 2010)
New Revision: 1140

Modified:
   wasko/branches/2.0/waskaweb/controllers/caseappointment.py
Log:
* waskaweb/controllers/caseappointment.py (loadCase): New. Helper
function to load a case. 
* waskaweb/controllers/caseappointment.py
(CaseappointmentController.newReminder): 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:10:16 UTC (rev 1139)
+++ wasko/branches/2.0/waskaweb/controllers/caseappointment.py	2010-02-02 14:29:18 UTC (rev 1140)
@@ -1,3 +1,4 @@
+# -*- coding: utf-8 -*-
 import logging
 from datetime import datetime
 
@@ -10,6 +11,7 @@
 from waskaweb.lib.base import BaseController, render
 from waskaweb.lib.helpers import url_for, dd_mm_YYYY, HH_MM 
 from waskaweb.lib.validators import CreateAppointmentForm 
+from waskaweb.model.case import CaseFactory, LoadCaseNotExistsError
 from waskaweb.model.appointment import CaseAppointmentOverview, \
      CaseAppointmentFactory, CaseReminderOverview
 from waskaweb.controllers.case import checkPrivacyStatement
@@ -27,6 +29,13 @@
 
 log = logging.getLogger(__name__)
 
+def loadCase(id):
+    factory = CaseFactory()
+    try:
+        return factory.loadById(id)
+    except LoadCaseNotExistsError, err:
+        self.showError()
+
 class CaseappointmentController(BaseController):
 
     def index(self, id):
@@ -53,6 +62,24 @@
         return formencode.htmlfill.render(unicode(form, 'utf-8'),
                                           defaults=form_defaults)
 
+    @checkRole('cm_ka')
+    def newReminder(self, id):
+        id = self._checkInt(id)
+        case = loadCase(id)
+        c.form_errors = {}
+        c.form_result = {}
+        cd = datetime.now()
+        form_defaults = {'start_date': dd_mm_YYYY(cd),
+                         'start_time': HH_MM(cd),
+                         'case_id': id,
+                         'title': u"%s, %s" % (case.last_name, case.first_name),
+                         'description': (u"Bitte geben Sie den Grund für"
+                                         u" die Wiedervorlage ein"),
+                         'type': 1}
+        form = render('/casemanagement/newAppointment.mako')
+        return formencode.htmlfill.render(unicode(form, 'utf-8'),
+                                          defaults=form_defaults)
+
     @checkRole(('cm_ka'))
     def newAction(self):
         validator = CreateAppointmentForm()



More information about the Mpuls-commits mailing list