[Mpuls-commits] r2663 - in wasko/branches/2.0/mpulsweb: controllers model
scm-commit@wald.intevation.org
scm-commit at wald.intevation.org
Wed May 5 16:47:07 CEST 2010
Author: torsten
Date: 2010-05-05 16:47:07 +0200 (Wed, 05 May 2010)
New Revision: 2663
Modified:
wasko/branches/2.0/mpulsweb/controllers/evaluate.py
wasko/branches/2.0/mpulsweb/model/phase.py
Log:
Fixed getting start and enddate for evaluation
Modified: wasko/branches/2.0/mpulsweb/controllers/evaluate.py
===================================================================
--- wasko/branches/2.0/mpulsweb/controllers/evaluate.py 2010-05-05 14:43:00 UTC (rev 2662)
+++ wasko/branches/2.0/mpulsweb/controllers/evaluate.py 2010-05-05 14:47:07 UTC (rev 2663)
@@ -16,6 +16,7 @@
from mpulsweb.lib.db import db
from mpulsweb.lib.helpers import format_date, get_phasesuccessors
from mpulsweb.lib.validators import EvaluationFormValidator
+from mpulsweb.model.phase import PhaseFactory
log = logging.getLogger(__name__)
@@ -36,19 +37,18 @@
SQL-Statements for evaluation based on the configuration. Note that
enddates will have a coalesce clause.'''
sdate, edate = None, None
- log.debug('Phase: %s.' % id)
- pair = g.mpuls_config.get('phases', 'pairs')[0].get(id)
- log.debug('Getting start and end date for phase %s.' % pair)
- for d in g.mpuls_config.get('phases', 'dates'):
- for k, v in d.iteritems():
- if k == pair[0]:
- sdate = v
- elif k == pair[1]:
- edate = "coalesce(%s, now())" % v
+ phaselist = PhaseFactory().build()
+ phase = None
+ for p in phaselist:
+ if p.id == id:
+ phase = p
+ if phase:
+ start, end = phase.start, phase.end
+ sdate = start.datefield
+ edate = "coalesce(%s, now())" % end.datefield
log.debug('sdate: %s, edate: %s' % (sdate, edate))
return sdate, edate
-
def get_search_options(soptions=None, id=None):
options = {}
options['id'] = id
Modified: wasko/branches/2.0/mpulsweb/model/phase.py
===================================================================
--- wasko/branches/2.0/mpulsweb/model/phase.py 2010-05-05 14:43:00 UTC (rev 2662)
+++ wasko/branches/2.0/mpulsweb/model/phase.py 2010-05-05 14:47:07 UTC (rev 2663)
@@ -91,7 +91,7 @@
end = EndPhasePart(pair[1], p,
self.suc.get(pair[1], []),
self.pre.get(pair[1], []))
- self.phases.append(Phase(start, end, desc))
+ self.phases.append(Phase(p, start, end, desc))
self.phases.set_suc(self.suc)
self.phases.set_pre(self.pre)
return self.phases
@@ -199,7 +199,8 @@
class Phase:
- def __init__(self, start, end, description):
+ def __init__(self, id, start, end, description):
+ self.id = id
self.start = start
self.end = end
self.description = description
More information about the Mpuls-commits
mailing list