[Mpuls-commits] r659 - in waska/trunk: . waskaweb/controllers waskaweb/model waskaweb/templates/casemanagement

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Tue Oct 27 12:19:23 CET 2009


Author: torsten
Date: 2009-10-27 12:19:21 +0100 (Tue, 27 Oct 2009)
New Revision: 659

Modified:
   waska/trunk/ChangeLog.txt
   waska/trunk/waskaweb/controllers/case.py
   waska/trunk/waskaweb/model/case.py
   waska/trunk/waskaweb/templates/casemanagement/digest_body.mako
Log:
Added phase information on digest page


Modified: waska/trunk/ChangeLog.txt
===================================================================
--- waska/trunk/ChangeLog.txt	2009-10-26 14:29:12 UTC (rev 658)
+++ waska/trunk/ChangeLog.txt	2009-10-27 11:19:21 UTC (rev 659)
@@ -1,3 +1,12 @@
+2009-09-26 	Torsten Irlaender  <torsten.irlaender at intevation.de>
+
+	Added information an phase to digest page
+
+	* waskaweb/model/case.py,
+	  waskaweb/controllers/case.py,
+	  waskaweb/templates/casemanagement/digest_body.mako: Added phase info
+	  and info on type of ending.
+
 2009-09-22 	Torsten Irlaender  <torsten.irlaender at intevation.de>
 
 	Set version to 1.5.6beta1

Modified: waska/trunk/waskaweb/controllers/case.py
===================================================================
--- waska/trunk/waskaweb/controllers/case.py	2009-10-26 14:29:12 UTC (rev 658)
+++ waska/trunk/waskaweb/controllers/case.py	2009-10-27 11:19:21 UTC (rev 659)
@@ -234,11 +234,38 @@
     return end_phase
 
 
+
 class CaseController(CasebaseController):
 
     def __before__(self):
         CasebaseController.__before__(self)
 
+    def _getStartEndeDateOfPhase(self, case):
+        '''Returns start and enddate (if any) of the current phase of the case'''
+        fields = case.getRequiredFields()
+        phase = case.getState().getPhase()
+        link = lambda ti: '"/case/%s/%d/%s"' % ('dummy', ti.realId(case.id), ti.key)
+        phase_pairs = phases_pairs(fields, phase, self.getNavigation(), link)
+
+        # get currently active pair
+        current_pair = None
+        for p in phase_pairs:
+            if phase == p.getStart().phase or phase == p.getEnd().phase:
+                current_pair = p
+
+        if current_pair:
+            phase = current_pair.getDescription()
+            state = current_pair.getStart().isRunning() and u"läuft" or u"beendet"
+            sdate = current_pair.getStart().getTime() 
+            edate = current_pair.getEnd().getTime() 
+        else:
+            phase = "Nicht gesetzt"
+            state = None
+            sdate = None
+            edate = None
+
+        return (phase, state, sdate, edate)
+
     @checkRole(('admin_ka', 'cm_ka', 'pt_dlr'))
     def index(self):
         redirect_to(controller="/case_overview")
@@ -262,6 +289,10 @@
     def digest(self, id):
         id = self._checkInt(id)
         case = self._loadCase(id)
+
+        # Information about current phase and possible ending
+        c.phasedescription, c.phasestate, c.start_date, c.end_date = self._getStartEndeDateOfPhase(case)
+        c.cmfinished = case.getState().getPhase() in (3,4,5)
         c.digest = case.getDigest()
         c.ds_id = id
         c.last_access = case.getState().getAccessTime('%d.%m.%Y %H:%M')
@@ -295,8 +326,15 @@
         formular = []
         c.print_version = 1
         # First page is print version of the digest ()
+        # Information about current phase and possible ending
+        c.phasedescription, c.phasestate, c.start_date, c.end_date = self._getStartEndeDateOfPhase(case)
+        c.cmfinished = case.getState().getPhase() in (3,4,5)
         c.digest = case.getDigest(empty)
+        c.finished = case.getState().isCmFinished()
+        c.canceled = case.getState().isCmCanceled()
+
         digest = render('/casemanagement/digest_body.mako')
+
         formular.append(unicode(digest, 'utf-8'))
         # append pagebreak
         formular.append('<span style="page-break-after:always"></span>')

Modified: waska/trunk/waskaweb/model/case.py
===================================================================
--- waska/trunk/waskaweb/model/case.py	2009-10-26 14:29:12 UTC (rev 658)
+++ waska/trunk/waskaweb/model/case.py	2009-10-27 11:19:21 UTC (rev 659)
@@ -113,7 +113,9 @@
     vorwahl_1, 
     telefon_1_1, 
     mobiltelefon_1, 
-    email_1 
+    email_1,
+    art_beendigung,
+    vermittlung
 FROM master_tbl_view WHERE id = %(id)s
 """
 
@@ -146,6 +148,9 @@
 
 ANONYMIZE_CASE          = """SELECT anonymize_case_wrapper(%(id)s)"""
 
+LOAD_ART_BEENDIGUNG = """SELECT value from art_beendigung_tbl where id = %(id)s"""
+LOAD_STATUS_BEENDIGUNG = """SELECT value from vermittlung_tbl where id = %(id)s"""
+
 class LoadCaseNotExistsError(Exception):
     def __init__(self, value):
         self.value = value
@@ -704,6 +709,30 @@
             self.parent_mobiletel   = unicode(str(result.get('mobiltelefon_1', '')), 'utf-8')
             self.parent_email       = unicode(str(result.get('email_1', '')), 'utf-8')
 
+            # Angaben zur Beendigung
+            art_id         = result.get('art_beendigung', '')
+            vermittlung_id = result.get('vermittlung', '')
+            conn, c = None, None
+            try:
+                conn = db.getConnection()
+                c    = conn.cursor(cursor_factory=psycopg2.extras.DictCursor)
+                try:
+
+                    fields = {'id': art_id}
+                    c.execute(LOAD_ART_BEENDIGUNG, fields)
+                    result = c.fetchone()
+                    self.type_ending = unicode(str(result.get('value', '')), 'utf-8')
+
+                    fields = {'id': vermittlung_id}
+                    c.execute(LOAD_STATUS_BEENDIGUNG, fields)
+                    result = c.fetchone()
+                    self.state_ending = unicode(str(result.get('value', '')), 'utf-8')
+                except:
+                    self.type_ending = None
+                    self.state_ending = None
+            finally:
+                db.recycleConnection(conn, c)
+
         except:
             traceback.print_exc(file=sys.stderr)
 

Modified: waska/trunk/waskaweb/templates/casemanagement/digest_body.mako
===================================================================
--- waska/trunk/waskaweb/templates/casemanagement/digest_body.mako	2009-10-26 14:29:12 UTC (rev 658)
+++ waska/trunk/waskaweb/templates/casemanagement/digest_body.mako	2009-10-27 11:19:21 UTC (rev 659)
@@ -37,17 +37,39 @@
     % endif
   </div>
   % else:
-  <p><strong>Letzte Bearbeitung: ${c.last_access} </strong>
-    % if c.daysToMaxSavetime <= 14:
-      % if c.finished or c.canceled:
-        (Tage bis zum Überschreiten der maximalen Speicherdauer: ${c.daysToMaxSavetime})
-      % else:
-        (Tage bis zur nächsten automatischen Wiedervorlage der Fallakte: ${c.daysToMaxSavetime})
-      % endif
+  <p><strong>Letzte Bearbeitung: ${c.last_access} </strong></p>
+  <p>
+  % if c.daysToMaxSavetime <= 14:
+    % if c.finished or c.canceled:
+      (Tage bis zum Überschreiten der maximalen Speicherdauer: ${c.daysToMaxSavetime})
+    % else:
+      (Tage bis zur nächsten automatischen Wiedervorlage der Fallakte: ${c.daysToMaxSavetime})
     % endif
+  % endif
   </p>
   % endif
 % endif
+<h2>${_('Angaben zum Verlauf')}</h2>
+<table class="">
+  <tr>
+    <td class="label table_header_v table_width_mid_l">${_('Phase')}</td>
+    <td class="table_row_v">${ c.phasedescription } ( ${ c.phasestate } )</td>
+  </tr>
+  <tr>
+    <td class="label">${_('Start- Enddatum')}</td>
+    <td class="table_row_v_2">( ${ h.dd_mm_YYYY(c.start_date, '-/-') | h } bis ${ h.dd_mm_YYYY(c.end_date, '-/-') | h } )</td>
+  </tr>
+  % if c.cmfinished: 
+  <tr>
+    <td class="label table_header_v table_width_mid_l">${_('Art Beendigung')}</td>
+    <td class="table_row_v">${c.digest.type_ending | h}</td>
+  </tr>
+  <tr>
+    <td class="label">${_('Status bei Beendigung')}</td>
+    <td class="table_row_v_2">${c.digest.state_ending | h}</td>
+  </tr>
+  % endif
+</table>
 <h2>${_('cm_header_digest_youth')}</h2>
 <table class="digest_table_left">
 	<tr>



More information about the Mpuls-commits mailing list