[Mpuls-commits] r2562 - wasko/branches/2.0/mpulsweb/model
scm-commit@wald.intevation.org
scm-commit at wald.intevation.org
Thu Apr 29 15:09:05 CEST 2010
Author: torsten
Date: 2010-04-29 15:08:58 +0200 (Thu, 29 Apr 2010)
New Revision: 2562
Modified:
wasko/branches/2.0/mpulsweb/model/phase.py
Log:
* mpulsweb/model/phase.py (PhasePart.getLinks): Only list fields as
missing if the are relevant
* mpulsweb/model/phase.py (Field.has_relevant_rules): Check if there
are relevant conditions
Modified: wasko/branches/2.0/mpulsweb/model/phase.py
===================================================================
--- wasko/branches/2.0/mpulsweb/model/phase.py 2010-04-29 11:01:59 UTC (rev 2561)
+++ wasko/branches/2.0/mpulsweb/model/phase.py 2010-04-29 13:08:58 UTC (rev 2562)
@@ -277,14 +277,18 @@
self.date = field.getValue()
def is_neighbor(self, phase):
- return (phase in self.suc) or (phase in self.pre)
+ return (str(phase )in self.suc) or (str(phase )in self.pre)
def getLinks(self):
out = []
if len(self.fields) > 0:
- for field in self.fields:
+ # Only add fields if they are relevant for the phase
+ # E.g ignore fields which are not required because of false
+ # conditional
+ for field in [field for field in self.fields
+ if field.has_relevant_rules()]:
out.append(field.get_link())
- else:
+ if len(out) == 0:
out.append(_('No required fields found'))
return ", ".join(out)
@@ -359,6 +363,14 @@
out.append('</a>')
return "".join(out)
+ def has_relevant_rules(self):
+ '''Returns true if the field has relevant rules. Else False e.g if the
+ required field is in a condition which is not true'''
+ for c in self.conditions:
+ if c.is_relevant():
+ return True
+ return False
+
def is_ok(self):
for c in self.conditions:
if not c.is_ok():
@@ -378,10 +390,15 @@
identified with name'''
return self.evaluate()
+ def is_relevant(self):
+ id = self.field.getIdentifier()
+ context = RuleEvalContext(self.it, id)
+ return self.it.rule_available(self.rule, context)
+
def evaluate(self):
id = self.field.getIdentifier()
context = RuleEvalContext(self.it, id)
- if not self.it.rule_available(self.rule, context): return True
+ if not self.is_relevant: return True
for result, variables in self.rule.getExpr().evaluate_instances(context):
if not result and id in variables:
return False
More information about the Mpuls-commits
mailing list