[Mpuls-commits] r2392 - wasko/branches/2.0/mpulsweb/model

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Fri Apr 16 09:20:07 CEST 2010


Author: torsten
Date: 2010-04-16 09:20:06 +0200 (Fri, 16 Apr 2010)
New Revision: 2392

Modified:
   wasko/branches/2.0/mpulsweb/model/phase.py
Log:
* mpulsweb/model/phase.py (Field.__init__): Remove handling of rg
out of Fieldclass.
* mpulsweb/model/phase.py (Field.__init__): Init Fields with
identifier instead of name.
* mpulsweb/model/phase.py (Field.get_link): Fixed generating of links.
* mpulsweb/model/phase.py (PhasePart.__init__): Initiate Fields with
identifier. Fixed Wald #1390.


Modified: wasko/branches/2.0/mpulsweb/model/phase.py
===================================================================
--- wasko/branches/2.0/mpulsweb/model/phase.py	2010-04-16 06:30:54 UTC (rev 2391)
+++ wasko/branches/2.0/mpulsweb/model/phase.py	2010-04-16 07:20:06 UTC (rev 2392)
@@ -189,7 +189,6 @@
 class PhasePart:
 
     def __init__(self, id, phase, it, suc, pre):
-        log.debug('Creating PhasePart with id: %s' % id)
         self.id = id
         self.it = it
         self.phase = phase
@@ -219,13 +218,14 @@
                 page = meta.getName()
             flags = get_flags(meta.getFlags())
 
-            # Check if this fields is a phase relvant required field 
             name = meta.getName()
+            identifier = p.getIdentifier()
+            # Check if this fields is a phase relvant required field 
             if id in flags['required']:
                 # Only add warnigs and rules with "required" in der name
                 rules = [rule for rule in formed.name2markingrules.get(name, ()) 
                          if rule.isWarning() and REQUIRED.match(rule.getName())]
-                self.fields.append(Field(name, page, rules, it))
+                self.fields.append(Field(identifier, page, rules, it))
             # Check if this fields is a phase relvant datefield
             if id in flags['time']:
                 realid = "%s:%s" % (name, case_id)
@@ -234,7 +234,6 @@
                 self.date = field.getValue()
 
     def is_neighbor(self, phase):
-        log.debug("phase: %s suc: %s, pre: %s" % (self.id, self.suc, self.pre))
         return (phase in self.suc) or (phase in self.pre)
 
     def getLinks(self):
@@ -291,31 +290,27 @@
 
 class Field:
 
-    def __init__(self, name, page, rules, it):
-        self.name = name
+    def __init__(self, id, page, rules, it):
+        self.id = id
         self.page = page
         self.it = it
         self.label = None
+        self.name = None
         self.conditions = []
 
-        case_id = self.it.getRootNode().getIdentifier()
-        real_id = "%s:%s" % (self.name, case_id)
-        field = self.it.getItem(real_id)
-        # TODO: Fix handling of RG
-        if field and not isinstance(field, RepeatInstanceContainerNode):
-            meta = field.getMeta()
-            self.label = meta.getDescription()
-            for rule in rules:
-                self.conditions.append(Condition(field, rule, it))
-        else:
-            log.warning('Can not find field %s' % real_id)
+        field = self.it.getItem(self.id)
+        meta = field.getMeta()
+        self.name = meta.getName()
+        self.label = meta.getDescription()
+        for rule in rules:
+            self.conditions.append(Condition(field, rule, it))
 
     def get_link(self):
         out = []
-        case_id = session['case'].id
         style = self.is_ok() and "ok" or "error"
-        out.append('<a class="%s" href="/formularpage/select/%s:%s#%s">'
-                   % (style, self.page, case_id, self.name))
+        element_id = ":".join(self.id.split(':')[1:])
+        out.append('<a class="%s" href="/formularpage/select/%s:%s#%s:%s">'
+                   % (style, self.page, element_id, self.name, element_id))
         out.append('%s' % self.label)
         out.append('</a>')
         return "".join(out)



More information about the Mpuls-commits mailing list