[Mpuls-commits] r2031 - wasko/branches/2.0/jmdweb/model
scm-commit@wald.intevation.org
scm-commit at wald.intevation.org
Fri Mar 19 10:58:32 CET 2010
Author: torsten
Date: 2010-03-19 10:58:32 +0100 (Fri, 19 Mar 2010)
New Revision: 2031
Modified:
wasko/branches/2.0/jmdweb/model/case.py
Log:
Fixed file (undo lowercase on whole file)
Modified: wasko/branches/2.0/jmdweb/model/case.py
===================================================================
--- wasko/branches/2.0/jmdweb/model/case.py 2010-03-19 09:57:30 UTC (rev 2030)
+++ wasko/branches/2.0/jmdweb/model/case.py 2010-03-19 09:58:32 UTC (rev 2031)
@@ -1,186 +1,187 @@
# -*- coding: utf-8 -*-
#
-# copyright 2007, 2008, 2010 intevation gmbh, germany, <info at intevation.de>
+# 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).
+# 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
+# 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.
+# 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/>.
+# 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:
-# torsten irländer <torsten.irlaender at intevation.de>
+# 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:
+# Torsten Irländer <torsten.irlaender at intevation.de>
#
import sys
from datetime import date, datetime
import traceback
import codecs
-import cstringio as stringio
-from sets import set
+import cStringIO as StringIO
+from sets import Set
import logging
import psycopg2.extras
from pylons.i18n import _
-from formed.meta import unknown_date
+from formed.meta import UNKNOWN_DATE
from mpulsweb.lib.base import session, g
from mpulsweb.lib.db import db
-from mpulsweb.model.user import userobject
-from mpulsweb.model.agencysettings import agency
-from mpulsweb.model.document import listdocuments
-from mpulsweb.model.case import mpulscase, mpulscasefactory, mpulscaseoverview, \
- mpulscasebundle, mpulscasestandin
+from mpulsweb.model.user import UserObject
+from mpulsweb.model.agencysettings import Agency
+from mpulsweb.model.document import listDocuments
+from mpulsweb.model.case import MpulsCase, MpulsCaseFactory, MpulsCaseOverview, \
+ MpulsCaseBundle, MpulsCaseStandin
-#from jmdweb.lib.csv import exportascsv
-#from jmdweb.lib.excel import exportasxls
-#from jmdweb.lib.xmlexport import exportasxml
+#from jmdweb.lib.csv import exportAsCSV
+#from jmdweb.lib.excel import exportAsXLS
+#from jmdweb.lib.xmlexport import exportAsXML
-from jmdweb.model.statement import privacystatement, discretionstatement
+from jmdweb.model.statement import PrivacyStatement, DiscretionStatement
from jmdweb.model.phase_transition import phase_description, phase_end, \
- cm_start, clear_start, clear_ende
-from jmdweb.model.phases_factory import requiredfields
+ CM_START, CLEAR_START, CLEAR_ENDE
+from jmdweb.model.phases_factory import RequiredFields
-log = logging.getlogger(__name__)
+log = logging.getLogger(__name__)
def save_getone(params, k, v):
try:
return params.getone(k)
- except keyerror:
+ except KeyError:
return v
-# sql statements
-load_casestate_sql = """
-select
+# SQL STATEMENTS
+LOAD_CASESTATE_SQL = """
+SELECT
s.id,
s.status,
s.zugriff,
- getlastcaseappointment(m.id) as letzer_termin,
- m.phase as phase
-from ka_status_tbl_view s join master_tbl_view m on m.id = s.master_id
-where s.master_id = %(id)s
+ getLastCaseAppointment(m.id) AS letzer_termin,
+ m.phase AS phase
+FROM ka_status_tbl_view s JOIN master_tbl_view m ON m.id = s.master_id
+WHERE s.master_id = %(id)s
"""
-set_casestate_sql = """
-update ka_status_tbl_view
- set status = %(status)s
- where id = %(id)s"""
+SET_CASESTATE_SQL = """
+UPDATE ka_status_tbl_view
+ SET status = %(status)s
+ WHERE id = %(id)s"""
-set_casephase_sql = """
- update master_tbl_view
- set phase = %(phase)s
- where id in (select master_id from ka_status_tbl_view where id = %(id)s)"""
+SET_CASEPHASE_SQL = """
+ UPDATE master_tbl_view
+ SET phase = %(phase)s
+ WHERE id IN (SELECT master_id FROM ka_status_tbl_view WHERE id = %(id)s)"""
-init_case_sql = """
-update master_tbl_view
-set
+INIT_CASE_SQL = """
+UPDATE master_tbl_view
+SET
mitarbeiter_vorname = %(vorname)s,
mitarbeiter_name = %(nachname)s
-where id = %(id)s"""
+WHERE id = %(id)s"""
-set_editor_name_sql = """
-select set_case_editor_name(%(firstname)s, %(lastname)s, %(caseid)s)"""
+SET_EDITOR_SQL = """SELECT set_case_editor(%(userid)s, %(caseid)s)"""
+SET_EDITOR_NAME_SQL = """
+SELECT set_case_editor_name(%(firstname)s, %(lastname)s, %(caseid)s)"""
-anonymize_case = """select anonymize_case_wrapper(%(id)s)"""
+ANONYMIZE_CASE = """SELECT anonymize_case_wrapper(%(id)s)"""
-class casebundle(mpulscasebundle):
+class CaseBundle(MpulsCaseBundle):
- def exportascsv(self, case_parts=none, anonymize=false):
- con, cur = none, none
- f = stringio.stringio()
- writer = codecs.getwriter('latin-1')
- out = writer(f, errors='replace')
+ def exportAsCSV(self, case_parts=None, anonymize=False):
+ con, cur = None, None
+ f = StringIO.StringIO()
+ Writer = codecs.getwriter('latin-1')
+ out = Writer(f, errors='replace')
try:
- con = db.getconnection()
+ con = db.getConnection()
cur = con.cursor()
- exportascsv(cur, out, self.listdatasetids(), case_parts, anonymize)
+ exportAsCSV(cur, out, self.listDatasetIds(), case_parts, anonymize)
out.flush()
bytes = out.getvalue()
out.close()
return bytes
finally:
- db.recycleconnection(con, cur)
+ db.recycleConnection(con, cur)
- def exportasxml(self, case_parts=none, anonymize=false):
- con, cur = none, none
- f = stringio.stringio()
- writer = codecs.getwriter('utf-8')
- out = writer(f, errors='replace')
+ def exportAsXML(self, case_parts=None, anonymize=False):
+ con, cur = None, None
+ f = StringIO.StringIO()
+ Writer = codecs.getwriter('utf-8')
+ out = Writer(f, errors='replace')
try:
- con = db.getconnection()
- cur = con.cursor(cursor_factory=psycopg2.extras.dictcursor)
- exportasxml(cur, out, self.listdatasetids(), case_parts, anonymize)
+ con = db.getConnection()
+ cur = con.cursor(cursor_factory=psycopg2.extras.DictCursor)
+ exportAsXML(cur, out, self.listDatasetIds(), case_parts, anonymize)
out.flush()
bytes = out.getvalue()
out.close()
return bytes
finally:
- db.recycleconnection(con, cur)
+ db.recycleConnection(con, cur)
- def exportasxls(self, case_parts=none, anonymize=false):
- con, cur = none, none
+ def exportAsXLS(self, case_parts=None, anonymize=False):
+ con, cur = None, None
try:
- con = db.getconnection()
+ con = db.getConnection()
cur = con.cursor()
- return exportasxls(cur, self.listdatasetids(), case_parts,
+ return exportAsXLS(cur, self.listDatasetIds(), case_parts,
anonymize)
finally:
- db.recycleconnection(con, cur)
+ db.recycleConnection(con, cur)
-class caseoverview(mpulscaseoverview):
+class CaseOverview(MpulsCaseOverview):
pass
-class casefactory(mpulscasefactory):
+class CaseFactory(MpulsCaseFactory):
- def _initnewcase(self, id):
- conn, cur = none, none
+ def _initNewCase(self, id):
+ conn, cur = None, None
try:
- user = session['user_authorized']
- agency = agency()
+ user = session['USER_AUTHORIZED']
+ agency = Agency()
fields = {
'vorname': user.first_name,
'nachname': user.last_name,
'id': int(id)
}
- conn = db.getconnection()
+ conn = db.getConnection()
cur = conn.cursor()
- cur.execute(init_case_sql, fields)
+ cur.execute(INIT_CASE_SQL, fields)
conn.commit()
finally:
- db.recycleconnection(conn, cur)
+ db.recycleConnection(conn, cur)
-class sessioncase:
+class SessionCase:
- """this class holds all needed information for the currently selected case
+ """This class holds all needed information for the currently selected case
"""
- def __init__(self, id=none, page_id=none, state=none,
- privacy_statement=false, **kw):
- if id is none:
- self.id = none
+ def __init__(self, id=None, page_id=None, state=None,
+ privacy_statement=False, **kw):
+ if id is None:
+ self.id = None
else:
self.id = int(id)
@@ -194,95 +195,95 @@
def _session_fields(self):
return g.case_factory.get_session_fields()
- def getstate(self):
+ def getState(self):
return self.state
- def setpageid(self, id):
+ def setPageId(self, id):
self.page_id = id
- def getpageid(self):
+ def getPageId(self):
return self.page_id
- def hasprivacystatement(self):
+ def hasPrivacyStatement(self):
return self.privacy_statement
- def setdata(self, params):
+ def setData(self, params):
for field in self._session_fields():
setattr(self, field.alias,
field.convert(save_getone(params, field.name,
field.default)))
- def toformdata(self):
+ def toFormData(self):
data = {}
for field in self._session_fields():
data[field.name] = getattr(self, field.alias)
return data
- def isyoungerthan(self, mydate):
- """return true if case was active relative to mydate.
+ def isYoungerThan(self, mydate):
+ """Return True if case was active relative to mydate.
- case either started or finished after mdate, or no end date set.
+ Case either started or finished after mdate, or no end date set.
"""
y, m, d = mydate.split('-')
if self.first_meeting:
if self.first_meeting > date(int(y), int(m), int(d)):
- return true
+ return True
elif self.cm_end and (self.cm_end <= date(int(y), int(m), int(d))
- and self.cm_end != unknown_date):
- return false
+ and self.cm_end != UNKNOWN_DATE):
+ return False
else:
- return true
- return true
+ return True
+ return True
-class case(mpulscase):
+class Case(MpulsCase):
- def __init__(self, id=none, preset=none, state_id=none, state_status=none,
- state_access=none):
- mpulscase.__init__(self, id=id, preset=preset)
+ def __init__(self, id=None, preset=None, state_id=None, state_status=None,
+ state_access=None):
+ MpulsCase.__init__(self, id=id, preset=preset)
self.init_state(state_id, state_status, state_access)
- self.standin = none
- self.digest = none
+ self.standin = None
+ self.digest = None
self.documents = []
self.appointments = []
- self.privacy_statement = none
- self.discretion_statement = none
+ self.privacy_statement = None
+ self.discretion_statement = None
def init_state(self, state_id, status, access):
- self.state = state(state_id, self.id, status, access)
+ self.state = State(state_id, self.id, status, access)
- def getstate(self):
+ def getState(self):
return self.state
- def setstate(self, value):
- self.state.setstate(value)
+ def setState(self, value):
+ self.state.setState(value)
- def getsessioncase(self):
- """return a sessioncase object initialized from the current case"""
+ def getSessionCase(self):
+ """Return a SessionCase object initialized from the current case"""
fields = dict()
for field in self.get_session_fields():
- # fixme: ideally we would use
- # self.get_value(field.name) to get the value. we use
+ # FIXME: Ideally we would use
+ # self.get_value(field.name) to get the value. We use
# getattr instead because this compatibility layer
- # translates none values into strings which some code
- # (e.g. buildinfofield in
+ # translates None values into strings which some code
+ # (e.g. buildInfofield in
# templates/casemanagement/main.mako) relies on.
fields[field.alias] = getattr(self, field.alias)
- signed = self.getprivacystatement().issigned()
- return sessioncase(self.id, state=self.state,
+ signed = self.getPrivacyStatement().isSigned()
+ return SessionCase(self.id, state=self.state,
privacy_statement=signed,
**fields)
- def seteditor(self, userid):
+ def setEditor(self, userid):
"""Sets the name of the editor in formular of the case. First call
setEditor function in baseclass to transfer the case to the new user.
After that set the name."""
MpulsCase.setEditor(self, userid)
- con, curr = None, None
+ con, cur = None, None
+ con = db.getConnection()
user = UserObject(userid)
fields = {'caseid': self.id, 'firstname': user.first_name,
'lastname': user.last_name}
- con = db.getConnection()
cur = con.cursor()
try:
cur.execute(SET_EDITOR_NAME_SQL, fields)
More information about the Mpuls-commits
mailing list