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

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Mon Feb 1 14:31:09 CET 2010


Author: torsten
Date: 2010-02-01 14:31:09 +0100 (Mon, 01 Feb 2010)
New Revision: 1062

Modified:
   wasko/branches/2.0/waskaweb/controllers/logbook.py
Log:
* waskaweb/controllers/logbook.py (LogbookController.editAcion): Moved
	  to logbook controller


Modified: wasko/branches/2.0/waskaweb/controllers/logbook.py
===================================================================
--- wasko/branches/2.0/waskaweb/controllers/logbook.py	2010-02-01 13:27:10 UTC (rev 1061)
+++ wasko/branches/2.0/waskaweb/controllers/logbook.py	2010-02-01 13:31:09 UTC (rev 1062)
@@ -162,6 +162,73 @@
             c.url_ok = "/case/logbook/%s" % str(session['case'].id)
             return render('/logbook/dialogs/failed_create_logbook_entry.mako')
 
+    @checkRole('cm_ka')
+    def edit(self, id):
+        id = self._checkInt(id)
+        c.form_errors = {}
+        entry_data = {}
+        try:
+            entry = LogbookEntry()
+            entry.loadById(id)
+            entry_data['id'] = entry.id
+            entry_data['date'] = entry.getDate()
+            entry_data['time'] = entry.getTime()
+            entry_data['duration'] = entry.getDuration()
+            entry_data['kind'] = entry.getKindAsInt()
+            entry_data['notice'] = entry.getNotice()
+            entry_data['short_notice'] = entry.getShortNotice()
+            c.entry = entry
+            form = render('/logbook/edit.mako')
+            return formencode.htmlfill.render(unicode(form, 'utf-8'),
+                                              defaults=entry_data,
+                                              auto_insert_errors=False,
+                                              errors={})
+        except Exception, e:
+            log.exception(e)
+            c.failed_for = LOGBOOK_ENTRY_SHOW_FAILED
+            c.failed_text = LOGBOOK_ENTRY_SHOW_FAILED_TEXT
+            c.url_ok = "/logbook/index/%s" % str(session['case'].id)
+            return render('/logbook/dialogs/failed_show_logbook_entry.mako')
+
+    @checkRole('cm_ka')
+    def editAction(self):
+        params = request.params
+        id = self._checkInt(params.getone('id'))
+        checker = LogbookEntryChecker(params, check_case_id=False)
+        validator = EditLogbookForm()
+
+        try:
+            form_result = validator.to_python(params)
+        except formencode.Invalid, error:
+            c.form_result = error.value
+            c.form_errors = error.error_dict or {}
+            form = render('/logbook/new.mako')
+            return formencode.htmlfill.render(unicode(form, 'utf-8'),
+                                              defaults=c.form_result,
+                                              auto_insert_errors=False,
+                                              errors=c.form_errors)
+
+        #if checker.hasErrors():
+        #    c.errors = checker.getErrors()
+        #    c.entry  = checker.getLogbookEntry()
+        #    c.entry.setId(id)
+        #    return render('/logbook/edit.mako')
+
+        try:
+            entry = checker.getLogbookEntry()
+            entry.setId(id)
+            entry.storeForUser(session['USER_AUTHORIZED'].id)
+            c.success_for = LOGBOOK_ENTRY_SAVE_SUCCESS
+            c.success_text = LOGBOOK_ENTRY_SAVE_SUCCESS_TEXT
+            c.url_ok = "/logbook/index/%s" % str(session['case'].id)
+            return render('/logbook/dialogs/success_save_logbook_entry.mako')
+        except Exception, e:
+            log.exception(e)
+            c.failed_for = LOGBOOK_ENTRY_SAVE_FAILED
+            c.failed_text = LOGBOOK_ENTRY_SAVE_FAILED_TEXT
+            c.url_ok = "/logbook/index/%s" % str(session['case'].id)
+            return render('/logbook/dialogs/failed_save_logbook_entry.mako')
+
     @checkRole(('cm_ka'))
     def printout(self, id):
         id = self._checkInt(id)



More information about the Mpuls-commits mailing list