[Mpuls-commits] r1601 - in wasko/branches/2.0: . mpulsweb/model waskaweb/model

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Tue Feb 16 11:15:33 CET 2010


Author: torsten
Date: 2010-02-16 11:15:32 +0100 (Tue, 16 Feb 2010)
New Revision: 1601

Added:
   wasko/branches/2.0/mpulsweb/model/logbook.py
Removed:
   wasko/branches/2.0/waskaweb/model/logbook.py
Modified:
   wasko/branches/2.0/ChangeLog
Log:
Moved model.logbook to mpulsweb


Modified: wasko/branches/2.0/ChangeLog
===================================================================
--- wasko/branches/2.0/ChangeLog	2010-02-16 10:14:56 UTC (rev 1600)
+++ wasko/branches/2.0/ChangeLog	2010-02-16 10:15:32 UTC (rev 1601)
@@ -20,6 +20,12 @@
 	  waskaweb/lib/evaluation.py: Moved evaluation to mpulsweb.
 	* waskaweb/model/logbook.py: Import evaluation from mpulsweb now.
 
+	* mpulsweb/model/logbook.py,
+	  waskaweb/model/logbook.py: Moved model.logbook to mpulsweb
+	* waskaweb/controllers/logbook.py: Import model logbook from mpulsweb. 
+	* waskaweb/controllers/case.py: Import model logbook from mpulsweb. 
+	* waskaweb/controllers/caselifetime.py: Import model logbook from mpulsweb.
+
 2010-02-15  Bernhard Herzog  <bh at intevation.de>
 
 	* waskaweb/controllers/evaluate.py: The base package is called

Copied: wasko/branches/2.0/mpulsweb/model/logbook.py (from rev 1595, wasko/branches/2.0/waskaweb/model/logbook.py)
===================================================================
--- wasko/branches/2.0/waskaweb/model/logbook.py	2010-02-16 10:08:05 UTC (rev 1595)
+++ wasko/branches/2.0/mpulsweb/model/logbook.py	2010-02-16 10:15:32 UTC (rev 1601)
@@ -0,0 +1,391 @@
+# -*- coding: utf-8 -*-
+#
+# Copyright 2007, 2008, 2010 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.
+#
+# Authors:
+# Sascha L. Teichmann <sascha.teichmann at intevation.de>
+
+import re
+import logging
+from datetime import timedelta, datetime
+
+from pylons import app_globals as g 
+import mpulsweb.lib.helpers as h
+from mpulsweb.lib.db import db
+from mpulsweb.lib.evaluation import LogbookEvaluation 
+
+log = logging.getLogger(__name__)
+
+KIND2TEXT = g.mpuls_config.get('logbook', 'descriptions')[0]
+
+ALLOWED_SORTING = ['name', 'art', 'dauer', 'datum', 'asc', 'desc']
+LOAD_LOGBOOK = """
+SELECT l.id AS id, datum, bearbeiter, art, kurz_notiz, notiz, dauer
+FROM ka_logbuch_tbl_view l WHERE l.master_id = %s
+ORDER BY %s %s
+"""
+
+LOAD_LOGBOOK_BY_ID = """
+SELECT l.id AS id, datum, bearbeiter, art, kurz_notiz, notiz, dauer
+FROM ka_logbuch_tbl_view l WHERE l.id = %(mid)s
+"""
+
+CREATE_LOGBOOK_ENTRY = """
+SELECT create_logbuch_ds(%(mid)s, NULL)
+"""
+
+DELETE_LOGBOOK_ENTRY = """
+SELECT delete_logbuch_ds(%(mid)s)
+"""
+
+UPDATE_LOGBOOK_ENTRY = """
+UPDATE ka_logbuch_tbl_view SET
+    datum      = %(date)s,
+    art        = %(kind)s,
+    kurz_notiz = %(short_notice)s,
+    notiz      = %(notice)s,
+    dauer      = %(duration)s
+WHERE id = %(id)s
+"""
+
+VALID_DATE = re.compile(r'^([0-9]{1,2})\.([0-9]{1,2})\.([0-9]{4})$')
+
+def checkDate(value):
+    m = VALID_DATE.match(value)
+    if not m:
+        return None
+    try:
+        return datetime(int(m.group(3)), int(m.group(2)), int(m.group(1)))
+    except ValueError:
+        return None
+
+
+VALID_TIME = re.compile(r'^([0-9]{1,2}):([0-9]{2})')
+
+def checkTime(value):
+    m = VALID_TIME.match(value)
+    if not m:
+        return None
+    return timedelta(hours = int(m.group(1)), minutes = int(m.group(2)))
+
+
+class LogbookEntry:
+
+    def __init__(self):
+        self.id = None
+        self.datum = None
+        self.art = None
+        self.bearbeiter_name = None
+        self.kurz_notiz = None
+        self.notiz = None
+        self.dauer = None
+
+    def setByRow(self, row):
+        self.id = row[0]
+        self.datum = row[1]
+        self.bearbeiter_name = row[2] and h.ensure_unicode(row[2]) or None
+        self.art = row[3]
+        self.kurz_notiz = row[4] and h.ensure_unicode(row[4]) or None
+        self.notiz = row[5] and h.ensure_unicode(row[5]) or None
+        self.dauer = row[6]
+
+    def loadById(self, id):
+        self.id = id
+        conn, cur = None, None
+        try:
+            conn = db.getConnection()
+            cur = conn.cursor()
+            cur.execute(LOAD_LOGBOOK_BY_ID, {'mid': id})
+            row = cur.fetchone()
+            if not row:
+                raise StandardError('logbook entry not found')
+            self.setByRow(row)
+        finally:
+            db.recycleConnection(conn, cur)
+
+    def setId(self, id):
+        self.id = id
+
+    def getId(self, id):
+        return self.id
+
+    def getDate(self):
+        return h.dd_mm_YYYY(self.datum)
+
+    def getTime(self):
+        return h.HH_MM(self.datum)
+
+    def setDate(self, datum):
+        self.datum = datum
+
+    def getEditor(self):
+        return self.bearbeiter_name
+
+    def getKind(self, empty='-/-'):
+        if self.art == -2:
+            return "%s" % self.getShortNotice(empty)
+        return KIND2TEXT.get(str(self.art), empty);
+
+    def setKind(self, art):
+        self.art = art
+
+    def getShortNotice(self, empty='-/-'):
+        if self.kurz_notiz is not None:
+            return self.kurz_notiz
+        return empty
+
+    def setShortNotice(self, kurz_notiz):
+        self.kurz_notiz = kurz_notiz
+
+    def getKindAsInt(self):
+        return self.art
+
+    def isSelectedKind(self, kind):
+        return kind == self.art and "selected" or ""
+
+    def setNotice(self, notice):
+        self.notiz = notice
+
+    def getNotice(self, empty=''):
+        if self.notiz:
+            return self.notiz
+        return empty
+
+    def getDuration(self, empty=''):
+        if self.dauer is None:
+            return empty
+        return "%d" % h.timedelta_in_minutes(self.dauer)
+
+    def setDuration(self, duration):
+        self.dauer = duration
+
+    def store(self, cur, mid, uid):
+        if self.id is None:
+            cur.execute(CREATE_LOGBOOK_ENTRY, {"mid": mid})
+            row = cur.fetchone()
+            if not row:
+                raise StandardError("Cannot create log book entry")
+            self.id = row[0]
+
+        cur.execute(UPDATE_LOGBOOK_ENTRY,
+                    {"date": self.datum,
+                     "kind": self.art,
+                     "short_notice": self.kurz_notiz,
+                     "notice": self.notiz,
+                     "duration": self.dauer,
+                     "id": self.id})
+
+    def storeForUser(self, uid):
+        conn, cur = None, None
+        try:
+            conn = db.getConnection()
+            cur = conn.cursor()
+            cur.execute(UPDATE_LOGBOOK_ENTRY,
+                        {"date": self.datum,
+                         "kind": self.art,
+                         "short_notice": self.kurz_notiz,
+                         "notice": self.notiz,
+                         "duration": self.dauer,
+                         "id": self.id})
+            conn.commit()
+        finally:
+            db.recycleConnection(conn, cur)
+
+
+class Logbook:
+
+    def __init__(self, mid=None, sort_field='datum', sort_order='desc'):
+        self.entries = []
+        self.mid = mid
+        self.sort_field = sort_field
+        self.sort_order = sort_order
+
+    def deleteEntryById(self, mid):
+        conn, cur = None, None
+        try:
+            conn = db.getConnection()
+            cur = conn.cursor()
+            cur.execute(DELETE_LOGBOOK_ENTRY, {'mid': mid})
+            conn.commit()
+        finally:
+            db.recycleConnection(conn, cur)
+
+    def loadById(self, mid, sort_field='datum', sort_order='desc'):
+        self.mid = mid
+        self.sort_field = sort_field
+        self.sort_order = sort_order
+        conn, cur = None, None
+        try:
+            conn = db.getConnection()
+            cur = conn.cursor()
+            try:
+                # Removed prepared statement as quoting does not work
+                # for sorting e.g
+                # cur.execute(LOAD_LOGBOOK, {'mid': mid, 'field': sort_field,
+                #                            'order': sort_order})
+                if (sort_field not in ALLOWED_SORTING
+                    or sort_order not in ALLOWED_SORTING):
+                    sort_field = 'datum'
+                    sort_order = 'desc'
+                cur.execute(LOAD_LOGBOOK % (mid, sort_field, sort_order))
+            except:
+                print cur.query
+            while True:
+                row = cur.fetchone()
+                if not row:
+                    break
+                entry = LogbookEntry()
+                entry.setByRow(row)
+                self.entries.append(entry)
+        finally:
+            db.recycleConnection(conn, cur)
+
+    def hasEntries(self):
+        return len(self.entries) > 0
+
+    def getEntries(self):
+        return self.entries
+
+    def addEntry(self, entry):
+        log.debug(entry)
+        self.entries.append(entry)
+
+    def store(self, uid):
+        if self.mid is None:
+            return
+        conn, cur = None, None
+        try:
+            conn = db.getConnection()
+            cur = conn.cursor()
+            for entry in self.entries:
+                entry.store(cur, self.mid, uid)
+            conn.commit()
+        finally:
+            db.recycleConnection(conn, cur)
+
+    def getEvaluation(self):
+        eval = LogbookEvaluation(self.mid)
+        return eval.perform()
+
+
+class LogbookEntryChecker:
+
+    def __init__(self, params, check_case_id=True):
+        errors = []
+        datum = params.getone('date')
+        if datum:
+            ndatum = checkDate(datum)
+            if not ndatum:
+                errors.append("Datum '%s' ist nicht korrekt. (dd.MM.JJJJ)."
+                              % datum)
+            datum = ndatum
+        else:
+            datum = None
+
+        zeit = params.get('time')
+        if zeit:
+            nzeit = checkTime(zeit)
+            if nzeit is None:
+                errors.append("Uhrzeit '%s' ist nicht korrekt. (HH:MM)." % zeit)
+            elif datum:
+                datum += nzeit
+
+        self.case_id = None
+        if check_case_id:
+            case_id = params.getone('case_id')
+            if case_id is None:
+                errors.append("Es wurde keine Fallnummer gefunden.")
+            else:
+                try:
+                    case_id = int(case_id)
+                    self.case_id = case_id
+                except ValueError:
+                    errors.append("Fallnummer is keine Ganzzahl.");
+
+        art = params.getone('kind')
+        if art is None:
+            errors.append("Die Art des Eintrages wurde nicht angegeben.")
+        else:
+            try:
+                art = int(art)
+                if art < -2 or art > 10:
+                    errors.append("Die Art liegt ausserhalb des erlaubten"
+                                  " Bereiches.")
+            except ValueError:
+                errors.append("Die Art des Eintrages ist keine Ganzzahl.")
+                art = None
+
+        dauer = params.getone('duration')
+        odauer = dauer
+        if dauer:
+            try:
+                dauer = int(dauer)
+                if dauer < 0:
+                    raise ValueError()
+                dauer = timedelta(minutes=dauer)
+            except ValueError:
+                errors.append("Die Dauer '%s' ist keine positive Ganzzahl."
+                              % odauer)
+                dauer = None
+        else:
+            dauer = None
+
+        notiz = params.getone('notice')
+        if not notiz:
+            notiz = None
+
+        kurz_notiz = params.getone('short_notice')
+        if not kurz_notiz:
+            kurz_notiz = None
+
+        self.errors = errors
+
+        entry = LogbookEntry()
+        self.entry = entry
+
+        if not art is None:
+            entry.setKind(art)
+        if not datum is None:
+            entry.setDate(datum)
+        if not dauer is None:
+            entry.setDuration(dauer)
+        if not kurz_notiz is None:
+            entry.setShortNotice(kurz_notiz)
+        if not notiz is None:
+            entry.setNotice(notiz)
+
+    def hasErrors(self):
+        return len(self.errors) > 0
+
+    def getErrors(self):
+        return self.errors
+
+    def getLogbookEntry(self):
+        return self.entry
+
+    def getCaseId(self):
+        return self.case_id
+
+# vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8:


Property changes on: wasko/branches/2.0/mpulsweb/model/logbook.py
___________________________________________________________________
Name: svn:mergeinfo
   + 

Deleted: wasko/branches/2.0/waskaweb/model/logbook.py
===================================================================
--- wasko/branches/2.0/waskaweb/model/logbook.py	2010-02-16 10:14:56 UTC (rev 1600)
+++ wasko/branches/2.0/waskaweb/model/logbook.py	2010-02-16 10:15:32 UTC (rev 1601)
@@ -1,392 +0,0 @@
-# -*- coding: utf-8 -*-
-#
-# Copyright 2007, 2008, 2010 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.
-#
-# Authors:
-# Sascha L. Teichmann <sascha.teichmann at intevation.de>
-
-import re
-import logging
-from datetime import timedelta, datetime
-
-from pylons import app_globals as g 
-import mpulsweb.lib.helpers as h
-from mpulsweb.lib.db import db
-from mpulsweb.lib.evaluation import LogbookEvaluation 
-
-log = logging.getLogger(__name__)
-
-
-KIND2TEXT = g.mpuls_config.get('logbook', 'descriptions')[0]
-
-ALLOWED_SORTING = ['name', 'art', 'dauer', 'datum', 'asc', 'desc']
-LOAD_LOGBOOK = """
-SELECT l.id AS id, datum, bearbeiter, art, kurz_notiz, notiz, dauer
-FROM ka_logbuch_tbl_view l WHERE l.master_id = %s
-ORDER BY %s %s
-"""
-
-LOAD_LOGBOOK_BY_ID = """
-SELECT l.id AS id, datum, bearbeiter, art, kurz_notiz, notiz, dauer
-FROM ka_logbuch_tbl_view l WHERE l.id = %(mid)s
-"""
-
-CREATE_LOGBOOK_ENTRY = """
-SELECT create_logbuch_ds(%(mid)s, NULL)
-"""
-
-DELETE_LOGBOOK_ENTRY = """
-SELECT delete_logbuch_ds(%(mid)s)
-"""
-
-UPDATE_LOGBOOK_ENTRY = """
-UPDATE ka_logbuch_tbl_view SET
-    datum      = %(date)s,
-    art        = %(kind)s,
-    kurz_notiz = %(short_notice)s,
-    notiz      = %(notice)s,
-    dauer      = %(duration)s
-WHERE id = %(id)s
-"""
-
-VALID_DATE = re.compile(r'^([0-9]{1,2})\.([0-9]{1,2})\.([0-9]{4})$')
-
-def checkDate(value):
-    m = VALID_DATE.match(value)
-    if not m:
-        return None
-    try:
-        return datetime(int(m.group(3)), int(m.group(2)), int(m.group(1)))
-    except ValueError:
-        return None
-
-
-VALID_TIME = re.compile(r'^([0-9]{1,2}):([0-9]{2})')
-
-def checkTime(value):
-    m = VALID_TIME.match(value)
-    if not m:
-        return None
-    return timedelta(hours = int(m.group(1)), minutes = int(m.group(2)))
-
-
-class LogbookEntry:
-
-    def __init__(self):
-        self.id = None
-        self.datum = None
-        self.art = None
-        self.bearbeiter_name = None
-        self.kurz_notiz = None
-        self.notiz = None
-        self.dauer = None
-
-    def setByRow(self, row):
-        self.id = row[0]
-        self.datum = row[1]
-        self.bearbeiter_name = row[2] and h.ensure_unicode(row[2]) or None
-        self.art = row[3]
-        self.kurz_notiz = row[4] and h.ensure_unicode(row[4]) or None
-        self.notiz = row[5] and h.ensure_unicode(row[5]) or None
-        self.dauer = row[6]
-
-    def loadById(self, id):
-        self.id = id
-        conn, cur = None, None
-        try:
-            conn = db.getConnection()
-            cur = conn.cursor()
-            cur.execute(LOAD_LOGBOOK_BY_ID, {'mid': id})
-            row = cur.fetchone()
-            if not row:
-                raise StandardError('logbook entry not found')
-            self.setByRow(row)
-        finally:
-            db.recycleConnection(conn, cur)
-
-    def setId(self, id):
-        self.id = id
-
-    def getId(self, id):
-        return self.id
-
-    def getDate(self):
-        return h.dd_mm_YYYY(self.datum)
-
-    def getTime(self):
-        return h.HH_MM(self.datum)
-
-    def setDate(self, datum):
-        self.datum = datum
-
-    def getEditor(self):
-        return self.bearbeiter_name
-
-    def getKind(self, empty='-/-'):
-        if self.art == -2:
-            return "%s" % self.getShortNotice(empty)
-        return KIND2TEXT.get(str(self.art), empty);
-
-    def setKind(self, art):
-        self.art = art
-
-    def getShortNotice(self, empty='-/-'):
-        if self.kurz_notiz is not None:
-            return self.kurz_notiz
-        return empty
-
-    def setShortNotice(self, kurz_notiz):
-        self.kurz_notiz = kurz_notiz
-
-    def getKindAsInt(self):
-        return self.art
-
-    def isSelectedKind(self, kind):
-        return kind == self.art and "selected" or ""
-
-    def setNotice(self, notice):
-        self.notiz = notice
-
-    def getNotice(self, empty=''):
-        if self.notiz:
-            return self.notiz
-        return empty
-
-    def getDuration(self, empty=''):
-        if self.dauer is None:
-            return empty
-        return "%d" % h.timedelta_in_minutes(self.dauer)
-
-    def setDuration(self, duration):
-        self.dauer = duration
-
-    def store(self, cur, mid, uid):
-        if self.id is None:
-            cur.execute(CREATE_LOGBOOK_ENTRY, {"mid": mid})
-            row = cur.fetchone()
-            if not row:
-                raise StandardError("Cannot create log book entry")
-            self.id = row[0]
-
-        cur.execute(UPDATE_LOGBOOK_ENTRY,
-                    {"date": self.datum,
-                     "kind": self.art,
-                     "short_notice": self.kurz_notiz,
-                     "notice": self.notiz,
-                     "duration": self.dauer,
-                     "id": self.id})
-
-    def storeForUser(self, uid):
-        conn, cur = None, None
-        try:
-            conn = db.getConnection()
-            cur = conn.cursor()
-            cur.execute(UPDATE_LOGBOOK_ENTRY,
-                        {"date": self.datum,
-                         "kind": self.art,
-                         "short_notice": self.kurz_notiz,
-                         "notice": self.notiz,
-                         "duration": self.dauer,
-                         "id": self.id})
-            conn.commit()
-        finally:
-            db.recycleConnection(conn, cur)
-
-
-class Logbook:
-
-    def __init__(self, mid=None, sort_field='datum', sort_order='desc'):
-        self.entries = []
-        self.mid = mid
-        self.sort_field = sort_field
-        self.sort_order = sort_order
-
-    def deleteEntryById(self, mid):
-        conn, cur = None, None
-        try:
-            conn = db.getConnection()
-            cur = conn.cursor()
-            cur.execute(DELETE_LOGBOOK_ENTRY, {'mid': mid})
-            conn.commit()
-        finally:
-            db.recycleConnection(conn, cur)
-
-    def loadById(self, mid, sort_field='datum', sort_order='desc'):
-        self.mid = mid
-        self.sort_field = sort_field
-        self.sort_order = sort_order
-        conn, cur = None, None
-        try:
-            conn = db.getConnection()
-            cur = conn.cursor()
-            try:
-                # Removed prepared statement as quoting does not work
-                # for sorting e.g
-                # cur.execute(LOAD_LOGBOOK, {'mid': mid, 'field': sort_field,
-                #                            'order': sort_order})
-                if (sort_field not in ALLOWED_SORTING
-                    or sort_order not in ALLOWED_SORTING):
-                    sort_field = 'datum'
-                    sort_order = 'desc'
-                cur.execute(LOAD_LOGBOOK % (mid, sort_field, sort_order))
-            except:
-                print cur.query
-            while True:
-                row = cur.fetchone()
-                if not row:
-                    break
-                entry = LogbookEntry()
-                entry.setByRow(row)
-                self.entries.append(entry)
-        finally:
-            db.recycleConnection(conn, cur)
-
-    def hasEntries(self):
-        return len(self.entries) > 0
-
-    def getEntries(self):
-        return self.entries
-
-    def addEntry(self, entry):
-        log.debug(entry)
-        self.entries.append(entry)
-
-    def store(self, uid):
-        if self.mid is None:
-            return
-        conn, cur = None, None
-        try:
-            conn = db.getConnection()
-            cur = conn.cursor()
-            for entry in self.entries:
-                entry.store(cur, self.mid, uid)
-            conn.commit()
-        finally:
-            db.recycleConnection(conn, cur)
-
-    def getEvaluation(self):
-        eval = LogbookEvaluation(self.mid)
-        return eval.perform()
-
-
-class LogbookEntryChecker:
-
-    def __init__(self, params, check_case_id=True):
-        errors = []
-        datum = params.getone('date')
-        if datum:
-            ndatum = checkDate(datum)
-            if not ndatum:
-                errors.append("Datum '%s' ist nicht korrekt. (dd.MM.JJJJ)."
-                              % datum)
-            datum = ndatum
-        else:
-            datum = None
-
-        zeit = params.get('time')
-        if zeit:
-            nzeit = checkTime(zeit)
-            if nzeit is None:
-                errors.append("Uhrzeit '%s' ist nicht korrekt. (HH:MM)." % zeit)
-            elif datum:
-                datum += nzeit
-
-        self.case_id = None
-        if check_case_id:
-            case_id = params.getone('case_id')
-            if case_id is None:
-                errors.append("Es wurde keine Fallnummer gefunden.")
-            else:
-                try:
-                    case_id = int(case_id)
-                    self.case_id = case_id
-                except ValueError:
-                    errors.append("Fallnummer is keine Ganzzahl.");
-
-        art = params.getone('kind')
-        if art is None:
-            errors.append("Die Art des Eintrages wurde nicht angegeben.")
-        else:
-            try:
-                art = int(art)
-                if art < -2 or art > 10:
-                    errors.append("Die Art liegt ausserhalb des erlaubten"
-                                  " Bereiches.")
-            except ValueError:
-                errors.append("Die Art des Eintrages ist keine Ganzzahl.")
-                art = None
-
-        dauer = params.getone('duration')
-        odauer = dauer
-        if dauer:
-            try:
-                dauer = int(dauer)
-                if dauer < 0:
-                    raise ValueError()
-                dauer = timedelta(minutes=dauer)
-            except ValueError:
-                errors.append("Die Dauer '%s' ist keine positive Ganzzahl."
-                              % odauer)
-                dauer = None
-        else:
-            dauer = None
-
-        notiz = params.getone('notice')
-        if not notiz:
-            notiz = None
-
-        kurz_notiz = params.getone('short_notice')
-        if not kurz_notiz:
-            kurz_notiz = None
-
-        self.errors = errors
-
-        entry = LogbookEntry()
-        self.entry = entry
-
-        if not art is None:
-            entry.setKind(art)
-        if not datum is None:
-            entry.setDate(datum)
-        if not dauer is None:
-            entry.setDuration(dauer)
-        if not kurz_notiz is None:
-            entry.setShortNotice(kurz_notiz)
-        if not notiz is None:
-            entry.setNotice(notiz)
-
-    def hasErrors(self):
-        return len(self.errors) > 0
-
-    def getErrors(self):
-        return self.errors
-
-    def getLogbookEntry(self):
-        return self.entry
-
-    def getCaseId(self):
-        return self.case_id
-
-# vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8:



More information about the Mpuls-commits mailing list