[Mpuls-commits] r1606 - in wasko/branches/2.0: . mpulsweb/controllers waskaweb/controllers
scm-commit@wald.intevation.org
scm-commit at wald.intevation.org
Tue Feb 16 11:26:24 CET 2010
Author: torsten
Date: 2010-02-16 11:26:21 +0100 (Tue, 16 Feb 2010)
New Revision: 1606
Added:
wasko/branches/2.0/mpulsweb/controllers/logbook.py
Removed:
wasko/branches/2.0/waskaweb/controllers/logbook.py
Modified:
wasko/branches/2.0/ChangeLog
Log:
Moved logbook controller to base. Updated ChangeLog
Modified: wasko/branches/2.0/ChangeLog
===================================================================
--- wasko/branches/2.0/ChangeLog 2010-02-16 10:24:12 UTC (rev 1605)
+++ wasko/branches/2.0/ChangeLog 2010-02-16 10:26:21 UTC (rev 1606)
@@ -26,6 +26,17 @@
* waskaweb/controllers/case.py: Import model logbook from mpulsweb.
* waskaweb/controllers/caselifetime.py: Import model logbook from mpulsweb.
+ * waskaweb/controllers/logbook.py: Import lib.base from mpulsweb
+ * mpulsweb/lib/validators.py (CreateLogbookForm), (EditLogbookForm):
+ Copied from waskaweb.lib.validators
+ * waskaweb/controllers/logbook.py: Import validators from mpulsweb
+ now.
+ * waskaweb/lib/validators.py (CreateLogbookForm), (EditLogbookForm):
+ Deleted. Defined in mpulsweb now.
+
+ * mpulsweb/controllers/logbook.py,
+ waskaweb/controllers/logbook.py: Moved controller to base.
+
2010-02-15 Bernhard Herzog <bh at intevation.de>
* waskaweb/controllers/evaluate.py: The base package is called
Copied: wasko/branches/2.0/mpulsweb/controllers/logbook.py (from rev 1604, wasko/branches/2.0/waskaweb/controllers/logbook.py)
Property changes on: wasko/branches/2.0/mpulsweb/controllers/logbook.py
___________________________________________________________________
Name: svn:mergeinfo
+
Deleted: wasko/branches/2.0/waskaweb/controllers/logbook.py
===================================================================
--- wasko/branches/2.0/waskaweb/controllers/logbook.py 2010-02-16 10:24:12 UTC (rev 1605)
+++ wasko/branches/2.0/waskaweb/controllers/logbook.py 2010-02-16 10:26:21 UTC (rev 1606)
@@ -1,274 +0,0 @@
-# -*- coding: utf-8 -*-
-#
-# Copyright 2007, 2008 Intevation GmbH, Germany, <info at intevation.de>
-#
-# This file is part of mpuls WASKA (CoMPUter-based case fiLeS -
-# Web-Anwendungs-Server fuer Kompetenzagenturen).
-#
-# mpuls WASKA is free software: you can redistribute it and/or modify it under
-# the terms of the GNU Affero General Public License as published by the
-# Free Software Foundation, either version 3 of the License, or (at your
-# option) any later version.
-#
-# mpuls WASKA is distributed in the hope that it will be useful, but WITHOUT
-# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public
-# License for more details.
-#
-# You should have received a copy of the GNU Affero General Public
-# License along with mpuls WASKA. If not, see <http://www.gnu.org/licenses/>.
-#
-# mpuls WASKA has been developed on behalf of the
-# Projekttraeger im Deutschen Zentrum fuer Luft- und Raumfahrt e.V. (PT-DLR)
-# within the programme Kompetenzagenturen (Durchfuehrungsphase) funded by
-# the Bundesministerium fuer Familie, Senioren, Frauen und Jugend and
-# European Social Fund resources.
-
-import sys
-import logging
-import formencode
-from datetime import datetime
-
-from mpulsweb.lib.security import checkRole
-from mpulsweb.model.logbook import Logbook, LogbookEntry, LogbookEntryChecker
-
-from mpulsweb.lib.base import BaseController, c, render, request, session
-from mpulsweb.lib.validators import CreateLogbookForm, EditLogbookForm
-
-LOGBOOK_ENTRY_CREATE_FAILED = u"Tagebucheintrag wurde nicht angelegt!"
-LOGBOOK_ENTRY_CREATE_FAILED_TEXT = u"\
-Beim Anlegen eines Tagebucheintrages is ein Fehler aufgetreten."
-
-CREATE_LOGBOOK_ENTRY_SUCCESS = u"Eintrag ins Tagebuch erfolgreich."
-CREATE_LOGBOOK_ENTRY_SUCCESS_TEXT = u"\
-Der Tagebucheintrag wurde erfolgreich durchgeführt."
-
-DELETE_LOGBOOK_ENTRY_CONFIRM = u"Tagebucheintrag löschen?"
-DELETE_LOGBOOK_ENTRY_CONFIRM_TEXT = u"""\
-Wollen Sie diesen Tagebucheintrag wirklich löschen?
-Er ginge damit unwiederbringlich verloren."""
-
-LOGBOOK_ENTRY_DELETE_SUCCESS = u"Tagebucheintrag erfolgreich gelöscht!"
-LOGBOOK_ENTRY_DELETE_SUCCESS_TEXT = u"\
-Der Tagebucheintrag wurde erfolgreich gelöscht!"
-
-LOGBOOK_ENTRY_DELETE_FAILED = u"Löschen des Tagebucheintrags fehlgeschlagen!"
-LOGBOOK_ENTRY_DELETE_FAILED_TEXT = u"\
-Beim Löschen des Tagebucheintrags ist ein Fehler aufgetreten."
-
-LOGBOOK_ENTRY_SHOW_FAILED = u"Anzeigen des Tagebucheintrags fehlgeschlagen!"
-LOGBOOK_ENTRY_SHOW_FAILED_TEXT = u"\
-Beim Anzeigen des Tagebucheintrags ist ein Fehler aufgetreten."
-
-LOGBOOK_ENTRY_SAVE_SUCCESS = u"Änderung des Eintrages erfolgreich!"
-LOGBOOK_ENTRY_SAVE_SUCCESS_TEXT = u"\
-Der Eintrag im Tagebuch wurde erfolgreich geändert."
-
-LOGBOOK_ENTRY_SAVE_FAILED = u"Änderung des Eintrages fehlgeschlagen!"
-LOGBOOK_ENTRY_SAVE_FAILED_TEXT = u"\
-Die Änderung des Eintrages im Tagebuch ist fehlgeschlagen."
-
-log = logging.getLogger(__name__)
-
-def get_sort(params):
- sort = params.get('sort_field', 'id')
- order = params.get('sort_order', 'asc')
- return sort, order
-
-class LogbookController(BaseController):
-
- @checkRole(('cm_ka'))
- def index(self, id):
- return self.overview(id)
-
- def overview(self, id):
- sort, order = get_sort(request.params)
- id = self._checkInt(id)
-
- # Load logbook
- logbook = Logbook()
- logbook.loadById(int(id), sort, order)
- c.logbook = logbook
-
- # Build evaluation
- c.eval_effort = logbook.getEvaluation()
- return render('/logbook/overview.mako')
-
- @checkRole(('cm_ka'))
- def show(self, id):
- id = self._checkInt(id)
- try:
- entry = LogbookEntry()
- entry.loadById(id)
- except 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)
- log.exception(e)
- return render('/logbook/dialogs/failed_show_logbook_entry.mako')
-
- c.entry = entry
- return render('/logbook/show.mako')
-
- @checkRole('cm_ka')
- def new(self, id):
- id = self._checkInt(id)
-
- entry = LogbookEntry()
- entry.setDate(datetime.now())
- entry.setKind(-1)
-
- form_defaults = {}
- c.form_errors = {}
-
- form_defaults['date'] = entry.getDate()
- form_defaults['time'] = entry.getTime()
- form_defaults['kind'] = entry.getKindAsInt()
- form_defaults['case_id'] = id
-
- form = render('/logbook/new.mako')
- return formencode.htmlfill.render(unicode(form, 'utf-8'),
- defaults=form_defaults,
- auto_insert_errors=False,
- errors=c.form_errors)
-
- @checkRole('cm_ka')
- def newAction(self):
- checker = LogbookEntryChecker(request.params)
- validator = CreateLogbookForm()
- c.form_errors = {}
- c.form_result = {}
-
- try:
- form_result = validator.to_python(request.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.ds_id = session['case'].id
- # c.entry = checker.getLogbookEntry()
- # c.form_errors = checker.getErrors()
-
- try:
- log.debug("New Logbook entry from case %s" % checker.getCaseId())
- logbook = Logbook(checker.getCaseId())
- logbook.addEntry(checker.getLogbookEntry())
- logbook.store(session['USER_AUTHORIZED'].id)
- c.url_ok = "/logbook/index/%s" % str(session['case'].id)
- c.success_for = CREATE_LOGBOOK_ENTRY_SUCCESS
- c.success_text = CREATE_LOGBOOK_ENTRY_SUCCESS_TEXT
- return render('/logbook/dialogs/success_create_logbook_entry.mako')
- except:
- traceback.print_exc(file=sys.stderr)
- c.failed_for = LOGBOOK_ENTRY_CREATE_FAILED
- c.failed_text = LOGBOOK_ENTRY_CREATE_FAILED_TEXT
- 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 delete(self, id, confirmed=False):
- id = self._checkInt(id)
- confirmed = self._checkBool(confirmed)
- if confirmed == 1:
- try:
- Logbook().deleteEntryById(int(id))
- c.success_for = LOGBOOK_ENTRY_DELETE_SUCCESS
- c.success_text = LOGBOOK_ENTRY_DELETE_SUCCESS_TEXT
- c.url_ok = "/case/logbook/%s" % str(session['case'].id)
- return render('/logbook/dialogs/success_delete_logbook_entry.mako')
- except Exception, e:
- log.exception(e)
- c.failed_for = LOGBOOK_ENTRY_DELETE_FAILED
- c.failed_text = LOGBOOK_ENTRY_DELETE_FAILED_TEXT
- c.url_ok = "/logbook/index/%s" % str(session['case'].id)
- return render('/logbook/dialogs/failed_delete_logbook_entry.mako')
- else:
- c.confirm_for = DELETE_LOGBOOK_ENTRY_CONFIRM
- c.question = DELETE_LOGBOOK_ENTRY_CONFIRM_TEXT
- c.url_yes = "/logbook/delete/%s/1" % id
- c.url_no = "/logbook/index/%s" % session['case'].id
- return render('/logbook/dialogs/confirm_delete_logbook_entry.mako')
-
- @checkRole(('cm_ka'))
- def printout(self, id):
- id = self._checkInt(id)
- c.print_version = 1
- logbook = Logbook()
- logbook.loadById(id)
- c.logbook = logbook
- return render('/logbook/overview_print.mako')
-
-# vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8:
More information about the Mpuls-commits
mailing list