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

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Wed Sep 3 16:18:31 CEST 2008


Author: teichmann
Date: 2008-09-03 16:18:30 +0200 (Wed, 03 Sep 2008)
New Revision: 129

Added:
   waska/trunk/waskaweb/model/phases.py
   waska/trunk/waskaweb/model/phases_factory.py
Removed:
   waska/trunk/waskaweb/lib/needed.py
Modified:
   waska/trunk/ChangeLog.txt
   waska/trunk/waskaweb/controllers/case.py
   waska/trunk/waskaweb/model/case.py
   waska/trunk/waskaweb/model/phase_transition.py
   waska/trunk/waskaweb/templates/casemanagement/phase.mako
Log:
Build phases table from FormEd tree.



Modified: waska/trunk/ChangeLog.txt
===================================================================
--- waska/trunk/ChangeLog.txt	2008-09-03 14:13:33 UTC (rev 128)
+++ waska/trunk/ChangeLog.txt	2008-09-03 14:18:30 UTC (rev 129)
@@ -1,5 +1,26 @@
 2008-09-03  Sascha L. Teichmann <sascha.teichmann at intevation.de>
 
+	Build phases table from FormEd tree.
+
+	* waskaweb/model/phases_factory.py: New. contains old needed.py stuff and
+	  is build list of phase pairs.
+
+	* waskaweb/model/phase_transition.py: Added method to check if two phases are
+	  neighbored.
+
+	* waskaweb/model/case.py: uses phases_factory now.
+
+	* waskaweb/model/phases.py: Models for phases and phase pairs
+
+	* waskaweb/controllers/case.py: rewired to use phases_factory now
+
+	* waskaweb/lib/needed.py: Removed. It's now integrated in  phases_factory.
+
+	* waskaweb/templates/casemanagement/phase.mako: Iterates over a list of
+	  phase pairs now. Remove hard wired phases.
+
+2008-09-03  Sascha L. Teichmann <sascha.teichmann at intevation.de>
+
 	* waskaweb/templates/casemanagement/main.mako: Show current phase in case digest
 
 	* waskaweb/model/case.py: Removed '#' before loading of phase from database.

Modified: waska/trunk/waskaweb/controllers/case.py
===================================================================
--- waska/trunk/waskaweb/controllers/case.py	2008-09-03 14:13:33 UTC (rev 128)
+++ waska/trunk/waskaweb/controllers/case.py	2008-09-03 14:18:30 UTC (rev 129)
@@ -68,6 +68,9 @@
 from waskaweb.model.data           import FilteredNodeComponentProxy
 from waskaweb.model.logbook        import Logbook, LogbookEntry, LogbookEntryChecker
 
+from waskaweb.model.phases_factory import phases_pairs
+from waskaweb.model.phases         import Phase
+
 from waskaweb.lib.db        import db
 from waskaweb.lib.xmlimport import importFromXML
 
@@ -688,24 +691,11 @@
         case   = self._loadCase(id)
         fields = case.getRequiredFields()
 
-        c.links_phase1 = fields.getLinkListForPhase('beratung_start')
-        c.complete_phase1 = fields.isPhaseComplete('beratung_start')
+        phase = case.getState().getPhase()
 
-        c.links_phase2 = fields.getLinkListForPhase('beratung_ende')
-        c.complete_phase2 = fields.isPhaseComplete('beratung_ende')
+        c.phase_pairs   = phases_pairs(fields, phase)
+        c.current_phase = Phase(phase, True)
 
-        c.links_phase3 = fields.getLinkListForPhase('cm_start')
-        c.complete_phase3 = fields.isPhaseComplete('cm_start')
-
-        c.links_phase4 = fields.getLinkListForPhase('cm_ende')
-        c.complete_phase4 = fields.isPhaseComplete('cm_ende')
-
-        c.links_phase5 = fields.getLinkListForPhase('nb_start')
-        c.complete_phase5 = fields.isPhaseComplete('nb_start')
-
-        c.links_phase6 = fields.getLinkListForPhase('nb_ende')
-        c.complete_phase6 = fields.isPhaseComplete('nb_ende')
-
         c.form_navigation  = self._getFormNavigation()
         return render('/casemanagement/phase.mako')
 

Deleted: waska/trunk/waskaweb/lib/needed.py
===================================================================
--- waska/trunk/waskaweb/lib/needed.py	2008-09-03 14:13:33 UTC (rev 128)
+++ waska/trunk/waskaweb/lib/needed.py	2008-09-03 14:18:30 UTC (rev 129)
@@ -1,168 +0,0 @@
-# -*- coding: utf-8 -*-
-#
-# Copyright 2007, 2008 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 <teichmann at intevation.de>
-#
-
-import sys
-
-IS_FILLED = \
-"""(%(name)s IS NOT NULL
-    AND (get_default_value('master_tbl', '%(name)s') IS NULL
-        OR %(name)s != get_default_value('master_tbl', '%(name)s')))
-"""
-
-SELECT = \
-''' SELECT %s FROM master_tbl_view WHERE id = %%(id)s
-'''
-
-BLACKLIST = set([
-    u'datum_ende_beratung',
-    u'foerderbedarf'])
-
-def description(nc):
-    p = nc
-    while p:
-        desc = p.getDescription()
-        if desc:
-            desc = desc.strip()
-            if desc: return desc
-        p = p.parent
-    return nc.getName()
-
-class RequiredFields:
-
-    def __init__(self):
-        self.phases = {}
-
-    def extractRequiredFields(self, document):
-
-        phases = {}
-
-        all = []
-        
-        for nc in document.walk():
-            flags = nc.getFlags()
-            if flags is None: continue
-            for pair in flags.split(';'):
-                pair = pair.strip()
-                if not pair: continue
-                p = [p.strip() for p in pair.split(':')]
-                if len(p) > 1:
-                    kind, phase = p[0], p[1]
-                    if kind == "required":
-                        for p in [p.strip() for p in phase.split(',')]:
-                            if p: phases.setdefault(p, []).append([nc, None])
-                else:
-                    # TODO: Fix formed tree
-                    if p[0] == "required":
-                        all.append([nc, None])
-
-        for a in all:
-            for v in phases.itervalues():
-                v.append(a)
-
-        for v in phases.itervalues():
-            v.sort(cmp=lambda a, b: cmp(description(a[0]), description(b[0])))
-
-        #for k in sorted(phases.iterkeys()):
-        #    print >> sys.stderr, "phase '%s': %s" % (
-        #        k, ', '.join([nc[0].getName() for nc in phases[k]]))
-
-        self.phases = phases
-            
-        return phases
-
-    def checkIfFilled(self, ds_id, cur):
-        fields = {}
-        idx = 0
-        for f in self.phases.itervalues():
-            for l in f:
-                name = l[0].getName()
-                if name in BLACKLIST:
-                    # print >> sys.stderr, "blacklist: %s" % name
-                    continue
-                if not fields.has_key(name):
-                    fields[name] = idx
-                    idx += 1
-
-        all = fields.items()
-        all.sort(cmp = lambda a, b: cmp(a[1], b[1]))
-
-        select_terms = []
-        for a in all:
-            select_terms.append(IS_FILLED % { 'name': a[0] })
-
-        select = SELECT % ', '.join(select_terms)
-
-        #print >> sys.stderr, '%s' % select
-
-        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.phases.itervalues():
-            for b in a:
-                b[1] = fields.get(b[0].getName())
-
-        # print >> sys.stderr, repr(self.phases.keys())
-
-        return True
-
-    def getPhase(self, phase):
-        return self.phases.get(phase)
-
-    def isPhaseComplete(self, phase):
-        try:
-            for l in self.phases[phase]:
-                if not l[1]:
-                    return False
-        except KeyError:
-            return False
-
-        return True
-
-    def getLinkListForPhase(self, phase):
-        try:
-            phase = self.phases[phase]
-        except KeyError:
-            return u""
-
-        out = []
-
-        for a in phase:
-            warn = (not a[1]) and ' class="required_missing"' or ""
-            link = '<a href="/case/required/%s" target="blank"%s>%s</a>' % (
-                a[0].getName(), warn, description(a[0]))
-            out.append(link)
-
-        return ',\n'.join(out)
-
-# vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8:

Modified: waska/trunk/waskaweb/model/case.py
===================================================================
--- waska/trunk/waskaweb/model/case.py	2008-09-03 14:13:33 UTC (rev 128)
+++ waska/trunk/waskaweb/model/case.py	2008-09-03 14:18:30 UTC (rev 129)
@@ -44,7 +44,6 @@
 from waskaweb.lib.csv import exportAsCSV
 from waskaweb.lib.excel import exportAsXLS
 from waskaweb.lib.xmlexport import exportAsXML
-from waskaweb.lib.needed import RequiredFields
 from waskaweb.lib.base import session, g, h, config 
 import waskaweb.lib.filters as F
 from waskaweb.lib.pdfimporter import asXFA, FieldExtractor
@@ -55,6 +54,7 @@
 from waskaweb.model.document import listDocuments 
 
 from waskaweb.model.phase_transition import phase_description
+from waskaweb.model.phases_factory   import RequiredFields
 
 from waskaweb.lib.helpers import dd_mm_yyyy_HH_MM, dd_mm_YYYY
 

Modified: waska/trunk/waskaweb/model/phase_transition.py
===================================================================
--- waska/trunk/waskaweb/model/phase_transition.py	2008-09-03 14:13:33 UTC (rev 128)
+++ waska/trunk/waskaweb/model/phase_transition.py	2008-09-03 14:18:30 UTC (rev 129)
@@ -38,6 +38,7 @@
 BERATUNG_START =  6
 BERATUNG_ENDE  =  7
 
+# dictionary for GUI
 PHASE_DESCRIPTIONS = {
     UNKNOWN        : u"Unbekannt",
     CLEAR_START    : u"Clearing läuft",
@@ -50,6 +51,19 @@
     BERATUNG_ENDE  : u"Beratung beendet"
 }
 
+# dictionary for symbolic handling like usage in FormEd trees.
+PHASE_SYMBOLS = {
+    UNKNOWN        : u"unbekannt",
+    CLEAR_START    : u"clearing_start",
+    CLEAR_ENDE     : u"clearing_ende",
+    CM_START       : u"cm_start",
+    CM_ENDE        : u"cm_ende",
+    NB_START       : u"nachbetreuung_start",
+    NB_ENDE        : u"nachbetreuung_ende",
+    BERATUNG_START : u"beratung_start",
+    BERATUNG_ENDE  : u"beratung_ende"
+}
+
 PHASE_SUCCESSORS = {
     UNKNOWN       : [CLEAR_START],
     CLEAR_START   : [CLEAR_ENDE],
@@ -64,6 +78,9 @@
 def phase_description(phase):
     return PHASE_DESCRIPTIONS.get(phase, "-/-")
 
+def phase_symbol(phase):
+    return PHASE_SYMBOLS[phase]
+
 def phase_successors(phase):
     try:
         return PHASE_SUCCESSORS[phase]
@@ -77,4 +94,12 @@
             preds.add(k)
     return list(preds)
 
+def phase_neighbors(phase1, phase2):
+    try:
+        succs1 = PHASE_SUCCESSORS[phase1]
+        if phase2 in succs1: return true
+        return phase1 in PHASE_SUCCESSORS[phase2]
+    except KeyError:
+        return false
+
 # vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8:

Added: waska/trunk/waskaweb/model/phases.py
===================================================================
--- waska/trunk/waskaweb/model/phases.py	2008-09-03 14:13:33 UTC (rev 128)
+++ waska/trunk/waskaweb/model/phases.py	2008-09-03 14:18:30 UTC (rev 129)
@@ -0,0 +1,89 @@
+# -*- coding: utf-8 -*-
+#
+# Copyright 2007, 2008 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>
+#
+
+from waskaweb.model.phase_transition import \
+    phase_neighbors, phase_symbol, phase_description
+
+class Phase:
+
+    def __init__(self, phase, running = False, complete = False, time = None, links = ""):
+        self.phase    = phase
+        self.running  = running
+        self.complete = complete
+        self.time     = time
+        self.links    = links
+
+    def isNeighbor(self, other):
+        return phase_neighbors(self.phase, other.phase)
+
+    def isRunning(self):
+        self.running
+
+    def getLabel(self):
+        return phase_symbol(self.phase)
+
+    def getDescription(self):
+        return phase_description(self.phase)
+
+    def isComplete(self):
+        return self.complete
+
+    def getTime(self):
+        return self.time
+
+    def getLinks(self):
+        return self.links
+
+class PhasePair:
+
+    def __init__(self, start, end, description):
+        self.start       = start
+        self.end         = end
+        self.description = description
+
+    def getStart(self):
+        return self.start
+
+    def getEnd(self):
+        return self.end
+
+    def getDuration(self):
+        t1 = self.start.getTime()
+        t2 = self.stop.getTime()
+        if not t1 or not t2: return None
+        return t2 - t1
+
+    def getDescription(self):
+        return self.description
+
+    def isRunning(self):
+        return self.start.isRunning() or self.end.isRunning()
+
+# vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8:

Added: waska/trunk/waskaweb/model/phases_factory.py
===================================================================
--- waska/trunk/waskaweb/model/phases_factory.py	2008-09-03 14:13:33 UTC (rev 128)
+++ waska/trunk/waskaweb/model/phases_factory.py	2008-09-03 14:18:30 UTC (rev 129)
@@ -0,0 +1,229 @@
+# -*- coding: utf-8 -*-
+#
+# Copyright 2007, 2008 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 sys
+
+from waskaweb.model.phases           import *
+from waskaweb.model.phase_transition import *
+
+IS_FILLED = \
+"""(%(name)s IS NOT NULL
+    AND (get_default_value('master_tbl', '%(name)s') IS NULL
+        OR %(name)s != get_default_value('master_tbl', '%(name)s')))
+"""
+
+SELECT = \
+''' SELECT %s FROM master_tbl_view WHERE id = %%(id)s
+'''
+
+def description(nc):
+    p = nc
+    while p:
+        desc = p.getDescription()
+        if desc:
+            desc = desc.strip()
+            if desc: return desc
+        p = p.parent
+    return nc.getName()
+
+class RequiredFields:
+
+    def __init__(self):
+        self.phases = {}
+
+    def extractRequiredFields(self, document):
+
+        phases = {}
+
+        all = []
+        
+        for nc in document.walk():
+            flags = nc.getFlags()
+            if flags is None: continue
+            for pair in flags.split(';'):
+                pair = pair.strip()
+                if not pair: continue
+                p = [p.strip() for p in pair.split(':')]
+                if len(p) > 1:
+                    kind, phase = p[0], p[1]
+                    if kind == "required":
+                        for p in [p.strip() for p in phase.split(',')]:
+                            if p: phases.setdefault(p, []).append([nc, None])
+                else:
+                    # TODO: Fix formed tree
+                    if p[0] == "required":
+                        all.append([nc, None])
+
+        for a in all:
+            for v in phases.itervalues():
+                v.append(a)
+
+        for v in phases.itervalues():
+            v.sort(cmp=lambda a, b: cmp(description(a[0]), description(b[0])))
+
+        #for k in sorted(phases.iterkeys()):
+        #    print >> sys.stderr, "phase '%s': %s" % (
+        #        k, ', '.join([nc[0].getName() for nc in phases[k]]))
+
+        self.phases = phases
+            
+        return phases
+
+    def checkIfFilled(self, ds_id, cur):
+        fields = {}
+        idx = 0
+        for f in self.phases.itervalues():
+            for l in f:
+                name = l[0].getName()
+                if not fields.has_key(name):
+                    fields[name] = idx
+                    idx += 1
+
+        all = fields.items()
+        all.sort(cmp = lambda a, b: cmp(a[1], b[1]))
+
+        select_terms = []
+        for a in all:
+            select_terms.append(IS_FILLED % { 'name': a[0] })
+
+        select = SELECT % ', '.join(select_terms)
+
+        #print >> sys.stderr, '%s' % select
+
+        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.phases.itervalues():
+            for b in a:
+                b[1] = fields.get(b[0].getName())
+
+        # print >> sys.stderr, repr(self.phases.keys())
+
+        return True
+
+    def getPhase(self, phase):
+        return self.phases.get(phase)
+
+    def isPhaseComplete(self, phase):
+        try:
+            for l in self.phases[phase]:
+                if not l[1]:
+                    return False
+        except KeyError:
+            return False
+
+        return True
+
+    def getLinkListForPhase(self, phase):
+        try:
+            phase = self.phases[phase]
+        except KeyError:
+            return u""
+
+        out = []
+
+        for a in phase:
+            warn = (not a[1]) and ' class="required_missing"' or ""
+            link = '<a href="/case/required/%s" target="blank"%s>%s</a>' % (
+                a[0].getName(), warn, description(a[0]))
+            out.append(link)
+
+        return ',\n'.join(out)
+
+def phases_pairs(required_fields, current_phase):
+
+    clear_start = Phase(
+        CLEAR_START,
+        CLEAR_START == current_phase,
+        required_fields.isPhaseComplete(phase_symbol(CLEAR_START)),
+        None,
+        required_fields.getLinkListForPhase(phase_symbol(CLEAR_START)))
+
+    clear_ende = Phase(
+        CLEAR_ENDE,
+        CLEAR_ENDE == current_phase,
+        required_fields.isPhaseComplete(phase_symbol(CLEAR_ENDE)),
+        None,
+        required_fields.getLinkListForPhase(phase_symbol(CLEAR_ENDE)))
+
+    cm_start = Phase(
+        CM_START,
+        CM_START == current_phase,
+        required_fields.isPhaseComplete(phase_symbol(CM_START)),
+        None,
+        required_fields.getLinkListForPhase(phase_symbol(CM_START)))
+
+    cm_ende = Phase(
+        CM_ENDE,
+        CM_ENDE == current_phase,
+        required_fields.isPhaseComplete(phase_symbol(CM_ENDE)),
+        None,
+        required_fields.getLinkListForPhase(phase_symbol(CM_ENDE)))
+
+    nb_start = Phase(
+        NB_START,
+        NB_START == current_phase,
+        required_fields.isPhaseComplete(phase_symbol(NB_START)),
+        None,
+        required_fields.getLinkListForPhase(phase_symbol(NB_START)))
+
+    nb_ende = Phase(
+        NB_ENDE,
+        NB_ENDE == current_phase,
+        required_fields.isPhaseComplete(phase_symbol(NB_ENDE)),
+        None,
+        required_fields.getLinkListForPhase(phase_symbol(NB_ENDE)))
+
+    berat_start = Phase(
+        BERATUNG_START,
+        BERATUNG_START == current_phase,
+        required_fields.isPhaseComplete(phase_symbol(BERATUNG_START)),
+        None,
+        required_fields.getLinkListForPhase(phase_symbol(BERATUNG_START)))
+
+    berat_ende = Phase(
+        BERATUNG_ENDE,
+        BERATUNG_ENDE == current_phase,
+        required_fields.isPhaseComplete(phase_symbol(BERATUNG_ENDE)),
+        None,
+        required_fields.getLinkListForPhase(phase_symbol(BERATUNG_ENDE)))
+
+    clear = PhasePair(clear_start, clear_ende, u"Clearing")
+    cm    = PhasePair(cm_start,    cm_ende,    u"Case-Management")
+    berat = PhasePair(berat_start, berat_ende, u"Beratung")
+    nb    = PhasePair(nb_start,    nb_ende,    u"Nachbetreuung")
+
+    return [ clear, cm, berat, nb ]
+
+# vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8:

Modified: waska/trunk/waskaweb/templates/casemanagement/phase.mako
===================================================================
--- waska/trunk/waskaweb/templates/casemanagement/phase.mako	2008-09-03 14:13:33 UTC (rev 128)
+++ waska/trunk/waskaweb/templates/casemanagement/phase.mako	2008-09-03 14:18:30 UTC (rev 129)
@@ -18,132 +18,53 @@
       <th class="table_header_h" width="15%">${_('case_cm_phase_time')}</th>
       <th style="text-align:right" class="table_header_h" width="20%">${_('case_cm_phase_change')}</th>
     </tr>
-    ##
-    ## BERATUNG 
-    ##
-    ## Start Beratung
+    % for phase_pair in c.phase_pairs:
+    <% p1, p2 = phase_pair.getStart(), phase_pair.getEnd()  %>
     <tr>
-      <td rowspan="2" class="cm_phase_state">Beratung (läuft)</td>
-      % if c.complete_phase1:
-      <td class="cm_phase_state_valid"></td>
-      % else:
-      <td class="cm_phase_state_invalid"></td>
-      % endif
-      <td class="required_field">
-        ${c.links_phase1}
-      </td>
-      <td >-/-</td>
-      <td style="text-align:right">
-        % if c.complete_phase1:
-        <input type="submit" value="Start Beratung" name="beratung_start">
-        % else:
-        <input type="submit" value="Start Beratung" name="beratung_start" disabled="disabled">
+      <td rowspan="2" class="cm_phase_state">
+        ${phase_pair.getDescription() | h}
+        % if phase_pair.isRunning():
+            <br>(läuft)
         % endif
       </td>
-    </tr>
-    ## Ende Beratung
-    <tr>
-      % if c.complete_phase2:
-      <td class="table_row_h cm_phase_state_valid"></td>
-      % else:
-      <td class="table_row_h cm_phase_state_invalid"></td>
-      % endif
-      <td class="table_row_h required_field">
-        ${c.links_phase2}
-      </td>
-      <td class="table_row_h">-/-</td>
-      <td style="text-align:right" class="table_row_h">
-        % if c.complete_phase2:
-        <input type="submit" value="Ende Beratung" name="beratung_ende">
-        % else:
-        <input type="submit" value="Ende Beratung" name="beratung_ende" disabled="disabled">
-        % endif
-      </td>
-    </tr>
-    ##
-    ## CASEMANAGEMENT
-    ##
-    ## Start CM
-    <tr>
-      <td rowspan="2" class="cm_phase_state">CM</td>
-      % if c.complete_phase3:
+      % if p1.isComplete():
       <td class="cm_phase_state_valid"></td>
       % else:
       <td class="cm_phase_state_invalid"></td>
       % endif
       <td class="required_field">
-        ${c.links_phase3}
+        ${p1.getLinks()}
       </td>
-      <td>-/-</td>
+      <td>${p1.getTime()}</td>
       <td style="text-align:right">
-        % if c.complete_phase2:
-        <input type="submit" value="Start CM" name="cm_start">
+        % if p1.isComplete() and not p1.isRunning() and p1.isNeighbor(c.current_phase):
+            <input type="submit" value="Start ${phase_pair.getDescription()|h}" name="${p1.getLabel()|h}">
         % else:
-        <input type="submit" value="Start CM" name="cm_start" disabled="disabled">
+            <input type="submit" value="Start ${phase_pair.getDescription()|h}" name="${p1.getLabel()|h}"
+              disabled="disabled">
         % endif
       </td>
     </tr>
-    ## Ende CM
     <tr>
-      % if c.complete_phase4:
-      <td class="table_row_h cm_phase_state_valid"></td>
+      % if p2.isComplete():
+          <td class="table_row_h cm_phase_state_valid"></td>
       % else:
-      <td class="table_row_h cm_phase_state_invalid"></td>
+          <td class="table_row_h cm_phase_state_invalid"></td>
       % endif
       <td class="table_row_h required_field">
-        ${c.links_phase4}
+        ${p2.getLinks()}
       </td>
-      <td class="table_row_h">-/-</td>
+      <td class="table_row_h">${p2.getTime()}</td>
       <td style="text-align:right" class="table_row_h">
-        % if c.complete_phase2:
-        <input type="submit" value="Ende CM" name="cm_ende">
+        % if p2.isComplete() and p2.isRunning():
+            <input type="submit" value="Ende ${p2.getDescription()|h}" name="${p2.getLabel()|h}">
         % else:
-        <input type="submit" value="Ende CM" name="cm_ende" disabled="disabled">
+            <input type="submit" value="Ende ${p2.getDescription()|h}" name="${p2.getLabel()|h}" 
+              disabled="disabled">
         % endif
       </td>
     </tr>
-    ##
-    ## NACHBETREUUNG 
-    ##
-    ## Start Nachbetreuung
-    <tr>
-      <td rowspan="2" class="cm_phase_state">Nach- betreuung</td>
-      % if c.complete_phase5:
-      <td class="cm_phase_state_valid"></td>
-      % else:
-      <td class="cm_phase_state_invalid"></td>
-      % endif
-      <td class="required_field">
-        ${c.links_phase5}
-      </td>
-      <td >-/-</td>
-      <td style="text-align:right">
-        % if c.complete_phase2:
-        <input type="submit" value="Start NB" name="nb_start">
-        % else:
-        <input type="submit" value="Ende NB" name="nb_start" disabled="disabled">
-        % endif
-      </td>
-    </tr>
-    ## Ende Nachbetreuung
-    <tr>
-      % if c.complete_phase6:
-      <td class="table_row_h cm_phase_state_valid"></td>
-      % else:
-      <td class="table_row_h cm_phase_state_invalid"></td>
-      % endif
-      <td class="table_row_h required_field">
-        ${c.links_phase6}
-      </td>
-      <td class="table_row_h">-/-</td>
-      <td style="text-align:right" class="table_row_h">
-        % if c.complete_phase6:
-        <input type="submit" value="Ende NB" name="nb_ende">
-        % else:
-        <input type="submit" value="Ende NB" name="nb_ende" disabled="disabled">
-        % endif
-      </td>
-    </tr>
+    % endfor
   </table>
 </form>
 </div>
@@ -158,14 +79,18 @@
       <th style="text-align:right" class="table_header_h">Dauer in Wochen</th>
     </tr>
     <tr>
-      <td>Beratungskunde</td>
+      <td>Clearing</td>
       <td style="text-align:right">???</td>
     </tr>
     <tr>
-      <td>CM</td>
+      <td>Case-Management</td>
       <td style="text-align:right">???</td>
     </tr>
     <tr>
+      <td>Beratungskunde</td>
+      <td style="text-align:right">???</td>
+    </tr>
+    <tr>
       <td>Nachbetreuung</td>
       <td style="text-align:right">???</td>
     </tr>



More information about the Mpuls-commits mailing list