[Mpuls-commits] r737 - in wasko/branches/1.0: . waskaweb/controllers waskaweb/i18n/de/LC_MESSAGES waskaweb/model waskaweb/public/styles waskaweb/templates/casemanagement

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Wed Dec 9 14:36:05 CET 2009


Author: torsten
Date: 2009-12-09 14:36:03 +0100 (Wed, 09 Dec 2009)
New Revision: 737

Added:
   wasko/branches/1.0/waskaweb/i18n/de/LC_MESSAGES/waskaweb.mo
Modified:
   wasko/branches/1.0/ChangeLog.txt
   wasko/branches/1.0/waskaweb/controllers/case.py
   wasko/branches/1.0/waskaweb/i18n/de/LC_MESSAGES/waskaweb.po
   wasko/branches/1.0/waskaweb/model/case.py
   wasko/branches/1.0/waskaweb/model/phases_factory.py
   wasko/branches/1.0/waskaweb/public/styles/screen.css
   wasko/branches/1.0/waskaweb/templates/casemanagement/digest_body.mako
Log:
Added phase information on digest page (backport from waska)


Modified: wasko/branches/1.0/ChangeLog.txt
===================================================================
--- wasko/branches/1.0/ChangeLog.txt	2009-12-08 10:20:40 UTC (rev 736)
+++ wasko/branches/1.0/ChangeLog.txt	2009-12-09 13:36:03 UTC (rev 737)
@@ -1,3 +1,17 @@
+2009-12-09 	Torsten Irlaender	<torsten.irlaender at intevation.de> 
+
+	Added additonal information on phase in digest
+
+	* waskaweb/model/phases_factory.py,
+	  waskaweb/model/case.py,
+	  waskaweb/controllers/case.py,
+	  waskaweb/public/styles/screen.css,
+	  waskaweb/templates/casemanagement/digest_body.mako: Added phase
+	  information on digest page
+
+	* waskaweb/i18n/de/LC_MESSAGES/waskaweb.po,
+	  waskaweb/i18n/de/LC_MESSAGES/waskaweb.mo: Set version
+
 2009-11-17 	Torsten Irlaender	<torsten.irlaender at intevation.de> 
 
 	Issue606

Modified: wasko/branches/1.0/waskaweb/controllers/case.py
===================================================================
--- wasko/branches/1.0/waskaweb/controllers/case.py	2009-12-08 10:20:40 UTC (rev 736)
+++ wasko/branches/1.0/waskaweb/controllers/case.py	2009-12-09 13:36:03 UTC (rev 737)
@@ -292,6 +292,34 @@
     def __before__(self):
         CasebaseController.__before__(self)
 
+    def _getStartEndeDateOfPhase(self, case):
+        '''Returns start and enddate (if any) of the current phase of the case'''
+        rf = RequiredFields(g.formedTree)
+        navigation = self.getNavigation()
+        phase = case.getState().getPhase()
+        session_case = session.get('case')
+        mode = session_case and session_case.getMode() or "show"
+        link = lambda ti, extra = "": '"/case/%s/%d/%s%s"' % (mode, session_case.id, ti.key, extra)
+        phase_pairs   = rf.phases_pairs(phase, navigation, 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")
@@ -315,8 +343,15 @@
     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.phase = case.getState().getPhase()
+        # call self.phase to get phase_pairs
+        self.phase(id)
         c.last_access = case.getState().getAccessTime('%d.%m.%Y %H:%M')
         c.daysToMaxSavetime = case.getState().daysToMaxSavetime()
         c.maxsavetime = case.getState().getMaxSavetime()
@@ -348,8 +383,14 @@
         formular = []
         c.print_version = 1
         # First page is print version of the digest ()
+        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>')

Added: wasko/branches/1.0/waskaweb/i18n/de/LC_MESSAGES/waskaweb.mo
===================================================================
(Binary files differ)


Property changes on: wasko/branches/1.0/waskaweb/i18n/de/LC_MESSAGES/waskaweb.mo
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Modified: wasko/branches/1.0/waskaweb/i18n/de/LC_MESSAGES/waskaweb.po
===================================================================
--- wasko/branches/1.0/waskaweb/i18n/de/LC_MESSAGES/waskaweb.po	2009-12-08 10:20:40 UTC (rev 736)
+++ wasko/branches/1.0/waskaweb/i18n/de/LC_MESSAGES/waskaweb.po	2009-12-09 13:36:03 UTC (rev 737)
@@ -8,7 +8,7 @@
 "Project-Id-Version: waskaweb 0.0.0\n"
 "Report-Msgid-Bugs-To: EMAIL at ADDRESS\n"
 "POT-Creation-Date: 2009-10-08 09:54+0200\n"
-"PO-Revision-Date: 2007-10-14 20:33+0200\n"
+"PO-Revision-Date: 2009-12-09 14:32+0100\n"
 "Last-Translator: Torsten Irländer<torsten.irlaender at intevation.de>\n"
 "Language-Team: de <LL at li.org>\n"
 "MIME-Version: 1.0\n"
@@ -453,7 +453,7 @@
 
 #: waskaweb/templates/main.mako:133
 msgid "footer_version"
-msgstr "23.10.2009 | Version 1.1.0"
+msgstr "09.12.2009 | Version 1.1.1beta1"
 
 #: waskaweb/templates/main_login.mako:39
 msgid "main_login_bmf_phrase"

Modified: wasko/branches/1.0/waskaweb/model/case.py
===================================================================
--- wasko/branches/1.0/waskaweb/model/case.py	2009-12-08 10:20:40 UTC (rev 736)
+++ wasko/branches/1.0/waskaweb/model/case.py	2009-12-09 13:36:03 UTC (rev 737)
@@ -122,7 +122,9 @@
     vater_telefonnummer1_1 , 
     vater_vorwahl2_1 , 
     vater_telefonnummer2_1 , 
-    vater_email_1 
+    vater_email_1,
+    cm_end_verm,
+    cm_end_art
 FROM master_tbl_view WHERE id = %(id)s
 """
 
@@ -156,6 +158,9 @@
 
 ANONYMIZE_CASE          = """SELECT anonymize_case_wrapper(%(id)s)"""
 
+LOAD_ART_BEENDIGUNG = """SELECT value from cm_dok_end_art_tbl where id = %(id)s"""
+LOAD_STATUS_BEENDIGUNG = """SELECT value from cm_dok_end_verm_tbl where id = %(id)s"""
+
 class LoadCaseNotExistsError(Exception):
     def __init__(self, value):
         self.value = value
@@ -776,6 +781,31 @@
             self.father_telephone_4 = unicode(str(result.get('vater_telefonnummer2_1', '')), 'utf-8')
             self.father_email       = unicode(str(result.get('vater_email_1', '')), 'utf-8')
 
+            # Angaben zur Beendigung
+            art_id         = result.get('cm_end_art', '')
+            vermittlung_id = result.get('cm_end_verm', '')
+
+            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)
 
@@ -1119,6 +1149,17 @@
             ps.keepUndefined()
         self.getState().setState(1)
 
+    def getRequiredFields(self):
+        con, cur = None, None
+        try:
+            con = db.getConnection()
+            cur = con.cursor()
+            rf = RequiredFields()
+            rf.extractRequiredFields(g.formedTree)
+            return rf.loadFromDatabase(self.id, cur) and rf or None
+        finally:
+            db.recycleConnection(con, cur)
+
     def getFirstMeeting(self):
         #TODO: See issue432 (WASKO). Fix this function. It seems to be not used anyway. 
         return self.first_meeting

Modified: wasko/branches/1.0/waskaweb/model/phases_factory.py
===================================================================
--- wasko/branches/1.0/waskaweb/model/phases_factory.py	2009-12-08 10:20:40 UTC (rev 736)
+++ wasko/branches/1.0/waskaweb/model/phases_factory.py	2009-12-09 13:36:03 UTC (rev 737)
@@ -80,7 +80,38 @@
         self.rule_eval_cache = {}
         self.var_eval_cache  = {}
 
+    def loadTimes(self, ds_id, cur):
+        fields = {}
+        idx = 0
+        for f in self.times.itervalues():
+            for l in f:
+                name = l[0].getName()
+                if not fields.has_key(name):
+                    fields[name] = idx
+                    idx += 1
 
+        all = fields.items()
+
+        if not all: return True
+
+        all.sort(cmp = lambda a, b: cmp(a[1], b[1]))
+
+        select = SELECT % ', '.join([a[0] for a in all])
+
+        cur.execute(select, { 'id': ds_id })
+        row = cur.fetchone()
+        if not row: return False
+
+        for a in all:
+            fields[a[0]] = row[a[1]]
+
+        for a in self.times.itervalues():
+            for b in a:
+                b[1] = fields.get(b[0].getName())
+
+        return True
+
+
     def getPhaseTime(self, phase):
         try:
             return self.phase_times[phase]

Modified: wasko/branches/1.0/waskaweb/public/styles/screen.css
===================================================================
--- wasko/branches/1.0/waskaweb/public/styles/screen.css	2009-12-08 10:20:40 UTC (rev 736)
+++ wasko/branches/1.0/waskaweb/public/styles/screen.css	2009-12-09 13:36:03 UTC (rev 737)
@@ -445,15 +445,14 @@
 	font-size: 0.8em;
 }
 
-
-#content_header #modusfield ul, #content_header #modusfield li, #content_header_small #modusfield ul, #content_header_small #modusfield li, #content_header_large #modusfield ul, #content_header_large #modusfield li{
+#content_header #modusfield ul, #content_header #modusfield li, #content_header_small #modusfield ul, #content_header_small #modusfield li{
 	display:inline;
 	list-style-type:none;
 	margin:0;
 	padding:0;
 }
 
-#content_header #modusfield a, #content_header_small #modusfield a, #content_header_large #modusfield a {
+#content_header #modusfield a, #content_header_small #modusfield a {
 	text-decoration:none;
 	padding:0 0.4em 0em 1.4em;
 	background-image:url(../images/arrow.gif);
@@ -462,6 +461,22 @@
 	background-position:0.4em 0.3em;
 }
 
+//#content_header #modusfield ul, #content_header #modusfield li, #content_header_small #modusfield ul, #content_header_small #modusfield li, #content_header_large #modusfield ul, #content_header_large #modusfield li{
+//	display:inline;
+//	list-style-type:none;
+//	margin:0;
+//	padding:0;
+//}
+//
+//#content_header #modusfield a, #content_header_small #modusfield a, #content_header_large #modusfield a {
+//	text-decoration:none;
+//	padding:0 0.4em 0em 1.4em;
+//	background-image:url(../images/arrow.gif);
+//	background-repeat:no-repeat;
+//	background-position:4px 4px!important;
+//	background-position:0.4em 0.3em;
+//}
+//
 label, select, input[type="checkbox"], input[type="radio"], 
 input[type="button"], input[type="submit"], input[type="file"] {
 	cursor: pointer;

Modified: wasko/branches/1.0/waskaweb/templates/casemanagement/digest_body.mako
===================================================================
--- wasko/branches/1.0/waskaweb/templates/casemanagement/digest_body.mako	2009-12-08 10:20:40 UTC (rev 736)
+++ wasko/branches/1.0/waskaweb/templates/casemanagement/digest_body.mako	2009-12-09 13:36:03 UTC (rev 737)
@@ -48,6 +48,44 @@
   </p>
   % endif
 % endif
+<h2>${_('Angaben zum Verlauf')}</h2>
+<table class="">
+  <tr>
+    <td class="label table_header_v table_width_mid_l">${_('Fallart')}</td>
+    <td class="table_row_v">
+      % if c.phase in (-1,0,1):
+        In der Klärung
+      % else:
+        Case Management
+      % endif
+    </td>
+  </tr>
+  <tr>
+    <td class="label table_width_mid_l">${_('Phase')}</td>
+    <td class="table_row_v_2">${ c.phasedescription } ( ${ c.phasestate } )</td>
+  </tr>
+  <tr>
+    <td class="label table_header_v">${_('Start- Enddaten')}</td>
+    <td class="table_row_v">
+    % for phase_pair in c.phase_pairs:
+      ## only show dates up to the current phase
+      % if phase_pair.getStart().phase <= c.phase or phase_pair.getEnd().phase <= c.phase:
+        ${phase_pair.getDescription()} (${h.dd_mm_YYYY(phase_pair.getStart().getTime(), '-/-')} bis ${h.dd_mm_YYYY(phase_pair.getEnd().getTime(), '-/-')})<br>
+      % endif
+    % endfor
+    </td>
+  </tr>
+  % if c.cmfinished: 
+  <tr>
+    <td class="label table_width_mid_l">${_('Art Beendigung')}</td>
+    <td class="table_row_v_2">${c.digest.type_ending | h}</td>
+  </tr>
+  <tr>
+    <td class="label table_header_v">${_('Status bei Beendigung')}</td>
+    <td class="table_row_v">${c.digest.state_ending | h}</td>
+  </tr>
+  % endif
+</table>
 <h2>${_('cm_header_digest_youth')}</h2>
 <table>
   <tr>



More information about the Mpuls-commits mailing list