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

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Mon Mar 29 18:32:00 CEST 2010


Author: bh
Date: 2010-03-29 18:31:57 +0200 (Mon, 29 Mar 2010)
New Revision: 2252

Modified:
   wasko/branches/2.0/ChangeLog
   wasko/branches/2.0/mpulsweb/model/case.py
Log:
* mpulsweb/model/case.py: Fix formatting.


Modified: wasko/branches/2.0/ChangeLog
===================================================================
--- wasko/branches/2.0/ChangeLog	2010-03-29 16:26:29 UTC (rev 2251)
+++ wasko/branches/2.0/ChangeLog	2010-03-29 16:31:57 UTC (rev 2252)
@@ -1,5 +1,9 @@
 2010-03-29  Bernhard Herzog  <bh at intevation.de>
 
+	* mpulsweb/model/case.py: Fix formatting.
+
+2010-03-29  Bernhard Herzog  <bh at intevation.de>
+
 	* mpulsweb/model/appointment.py: Fix formatting.
 
 2010-03-29  Bernhard Herzog  <bh at intevation.de>

Modified: wasko/branches/2.0/mpulsweb/model/case.py
===================================================================
--- wasko/branches/2.0/mpulsweb/model/case.py	2010-03-29 16:26:29 UTC (rev 2251)
+++ wasko/branches/2.0/mpulsweb/model/case.py	2010-03-29 16:31:57 UTC (rev 2252)
@@ -26,6 +26,7 @@
 # Authors:
 # Torsten Irländer <torsten.irlaender at intevation.de>
 #
+
 import logging
 from datetime import datetime
 from sets import Set
@@ -39,7 +40,7 @@
 from formed.instance.tree import SetDataException
 
 from mpulsweb.lib.base import g, session
-from mpulsweb.lib.anonymize import determineAnonymizedCaseEndPhase 
+from mpulsweb.lib.anonymize import determineAnonymizedCaseEndPhase
 from mpulsweb.lib.helpers import ensure_unicode
 from mpulsweb.lib.db import PostgresDBInterface, db
 
@@ -97,7 +98,11 @@
 """
 
 MARKANONYMIZE_FAILED_RUNNING_PHASE = u"""\
-<p>Eine Anonymisierung ist für diese Fallakte derzeit nicht möglich: Es können nur Fälle beendet werden, deren aktuelle Phase beendet wurde. Die Phase "%s" is derzeit noch nicht beendet. Bitte beenden Sie die Phase und versuchen Sie erneut eine Anonymisierung.</p> Klicken Sie auf "OK", um fortzufahren.</p>
+<p>Eine Anonymisierung ist für diese Fallakte derzeit nicht möglich:
+Es können nur Fälle beendet werden, deren aktuelle Phase beendet wurde.
+Die Phase "%s" is derzeit noch nicht beendet. Bitte beenden Sie die Phase
+und versuchen Sie erneut eine Anonymisierung.</p>
+Klicken Sie auf "OK", um fortzufahren.</p>
 """
 
 def save_getone(params, k, v):
@@ -106,6 +111,7 @@
     except KeyError:
         return v
 
+
 class LoadCaseNotExistsError(Exception):
 
     def __init__(self, value):
@@ -118,15 +124,15 @@
     """Will return the default value for a instance tree item"""
     meta = item.getMeta()
     if isinstance(meta, DateLeaf):
-        value  = '01.01.0001'
+        value = '01.01.0001'
     elif isinstance(meta, IntLeaf):
-       value  = '-999999'
+       value = '-999999'
     elif isinstance(meta, TextLeaf):
-       value  = 'unbekannt'
+       value = 'unbekannt'
     elif isinstance(meta, ChoiceNode):
-       value  = '-3'
+       value = '-3'
     else:
-       value  = None 
+       value = None
     return value
 
 def get_field_identifier(id, name, it=None, idx=0):
@@ -163,7 +169,6 @@
     return '%s:%s:%s' % (name, rg.getInternalIdentifier(), id)
 
 
-
 class Field(object):
 
     """Class providing extra information about an attribute of the case.
@@ -184,10 +189,10 @@
                default caseoverview
 
        overview_label -- Defines a label to be used in the overviewpage.
-               Default will be the name of the field. 
+               Default will be the name of the field.
 
        overview_style -- Defines a css style for the fields in the overview
-               (default table_name) 
+               (default table_name)
 
        search_retrieve -- If true (default false), the field will be
                returned from a search.  This only works if the name is a
@@ -241,7 +246,7 @@
         self.alias_force_string = alias_force_string
 
         self.overview = overview
-        self.overview_label = overview_label or name 
+        self.overview_label = overview_label or name
         self.overview_style = overview_style
 
     @property
@@ -262,6 +267,7 @@
             value = ensure_unicode(value)
         return value
 
+
 class MpulsCaseList:
 
     def __init__(self, case_ids=None):
@@ -286,6 +292,7 @@
             list.append(g.case_factory.loadById(id))
         return list
 
+
 class MpulsCaseBundle(MpulsCaseList):
 
     def __init__(self, case_ids=None):
@@ -379,7 +386,9 @@
 
 
 class MpulsCaseStandin:
+
     """This class represents the standin for a case"""
+
     def __init__(self, case_id=None):
         self.case_id = case_id
         self.group_ids = []
@@ -445,6 +454,7 @@
         finally:
             db.recycleConnection(con, cur)
 
+
 class MpulsCase:
 
     def __init__(self, id=None, preset=None, state_id=None, state_status=None,
@@ -617,7 +627,7 @@
     def check_consistence(self, fields=None):
         """Raises ConsistenceCheckException if the case is not completly
         consistent up to the current phase. A case is consistent if no required
-        field are missing and all relevant dates on phases are set. 
+        field are missing and all relevant dates on phases are set.
 
         fields: List of fieldnames which will be checked. On default all fields
                 will be checked
@@ -625,35 +635,38 @@
         self.get_phaseslist().check_consistence(fields)
 
     def check_anonymizeability(self, fields=None):
-        """Raises ConsistenceCheckException if the case is not in a anonymizable state.  
+        """Raises ConsistenceCheckException if the case is not in a
+        anonymizable state.
         """
-        # Check if anonymization is allowed in the current phase 
+        # Check if anonymization is allowed in the current phase
         phasepart = self.get_phaseslist().get_current_phase()
-        desc  = g.mpuls_config.get('phases', 'description')[0].get(phasepart.phase)
+        desc = g.mpuls_config.get('phases',
+                                  'description')[0].get(phasepart.phase)
         if not phasepart.is_anonymizable():
-            raise ConsistenceCheckException(
-                MARKANONYMIZE_FAILED_MIN_PHASE % desc)
+            raise ConsistenceCheckException(MARKANONYMIZE_FAILED_MIN_PHASE
+                                            % desc)
 
         #Check consistence
         self.check_consistence(fields)
 
         # Check if the current phase is currently running.
         if isinstance(phasepart, StartPhasePart):
-            raise ConsistenceCheckException(
-                MARKANONYMIZE_FAILED_RUNNING_PHASE % desc) 
+            raise ConsistenceCheckException(MARKANONYMIZE_FAILED_RUNNING_PHASE
+                                            % desc)
 
     def make_consistent(self):
         """Will ensure that the case is in a (minimal) consistent state. That
         means that all missing required fields up to the current phase are set
         to 'unknown'.  Missing relevant datefields (start, end) are set to the
-        current date. 
+        current date.
         """
         phaseslist = self.get_phaseslist()
         curphase = phaseslist.get_current_phase_id()
         data = {}
         for phase in phaseslist:
             start, end = phase.getStart(), phase.getEnd()
-            if start.id > curphase: break;
+            if start.id > curphase:
+                break
             for field in start.fields:
                 item = self._get_formed_item(field.name)
                 value = item.getValue()
@@ -662,7 +675,7 @@
                     def_value = get_default_value(item)
                     if def_value:
                         log.debug("Setting %s to %s" % (field.name, def_value))
-                        data["%s:%s" % (field.name, self.id)] = def_value 
+                        data["%s:%s" % (field.name, self.id)] = def_value
             for field in end.fields:
                 item = self._get_formed_item(field.name)
                 value = item.getValue()
@@ -671,7 +684,7 @@
                     def_value = get_default_value(item)
                     if def_value:
                         log.debug("Setting %s to %s" % (field.name, def_value))
-                        data["%s:%s" % (field.name, self.id)] = def_value 
+                        data["%s:%s" % (field.name, self.id)] = def_value
 
         # Set values
         self.formed_instance.setData(data)
@@ -764,7 +777,7 @@
         try:
             try:
                 conn = db.getConnection()
-                cur  = conn.cursor()
+                cur = conn.cursor()
                 d = {'id': self.id}
                 cur.execute(ANONYMIZE_CASE, d)
             finally:
@@ -783,6 +796,7 @@
             ps.keepUndefined()
         self.getState().setState(1)
 
+
 class SessionCase:
 
     """This class holds all needed information for the currently selected case
@@ -823,6 +837,7 @@
     def hasPrivacyStatement(self):
         return self.privacy_statement
 
+
 class MpulsCaseFactory:
 
     """Factory for case object. This factory provides methods to either load
@@ -936,6 +951,7 @@
         override this method if necessary.
         """
 
+
 class MpulsCaseOverview:
 
     def __init__(self):
@@ -944,7 +960,7 @@
     def search(self, search_str=None):
         self.ds_list = []
         search = g.case_search(g.case_factory.get_search_retrieve_fields(),
-                            g.case_factory.get_search_match_fields())
+                               g.case_factory.get_search_match_fields())
         result = search.perform(search_str)
         factory = g.case_factory
         for row in result:
@@ -958,6 +974,7 @@
     def getDatasets(self):
         return self.ds_list
 
+
 class MpulsCaseState(object):
 
     """This class store the state and the last accesstime of the case.
@@ -970,11 +987,11 @@
     """
 
     def __init__(self, id=None, master_id=None, state=None, access=None):
-        self.id         = id
-        self.master_id  = master_id
-        self.state      = state
-        self.access     = access
-        self.phase      = None
+        self.id = id
+        self.master_id = master_id
+        self.state = state
+        self.access = access
+        self.phase = None
         self._last_date = None
 
         if self.master_id is not None and self.id is None:
@@ -993,10 +1010,10 @@
     last_date = property(getLastDateFromDB)
 
     def setData(self, id, master_id, state, access):
-        self.master_id   = master_id
-        self.id          = id
-        self.state       = state
-        self.access      = access
+        self.master_id = master_id
+        self.id = id
+        self.state = state
+        self.access = access
 
     def _load(self):
         conn, cur = None, None
@@ -1005,11 +1022,11 @@
             cur = conn.cursor(cursor_factory=psycopg2.extras.DictCursor)
             cur.execute(LOAD_CASESTATE_SQL, {'id': self.master_id})
             result = cur.fetchone()
-            self.id          = result.get('id')
-            self.state       = result.get('status')
-            self.access      = result.get('zugriff')
-            self._last_date  = result.get('letzer_termin')
-            self.phase       = result.get('phase')
+            self.id = result.get('id')
+            self.state = result.get('status')
+            self.access = result.get('zugriff')
+            self._last_date = result.get('letzer_termin')
+            self.phase = result.get('phase')
         except:
             log.exception('Failed loading State')
             raise
@@ -1026,7 +1043,7 @@
         return state_labels.get(str(self.state))
 
     def isCmFinished(self):
-        return self.phase in g.mpuls_config.get('phases', 'finished') 
+        return self.phase in g.mpuls_config.get('phases', 'finished')
 
     def getState(self):
         return self.state
@@ -1037,7 +1054,7 @@
             try:
                 conn = db.getConnection()
                 cur = conn.cursor()
-                fields =  {'status': value, 'id': self.id}
+                fields = {'status': value, 'id': self.id}
                 cur.execute(SET_CASESTATE_SQL, fields)
                 conn.commit()
                 self.state = value
@@ -1057,7 +1074,7 @@
             try:
                 conn = db.getConnection()
                 cur = conn.cursor()
-                fields =  {'phase': phase, 'id': self.id}
+                fields = {'phase': phase, 'id': self.id}
                 cur.execute(SET_CASEPHASE_SQL, fields)
                 conn.commit()
                 self.phase = phase
@@ -1072,7 +1089,8 @@
         desc = []
         phases = PhaseFactory().load(self.master_id)
         phase = phases.get_current_phase()
-        desc.append(g.mpuls_config.get('phases', 'description')[0].get(phase.phase))
+        desc.append(g.mpuls_config.get('phases',
+                                       'description')[0].get(phase.phase))
         if phase.is_active():
             desc.append(_('Running'))
         else:



More information about the Mpuls-commits mailing list