[Mpuls-commits] r592 - in wasko/branches/1.0/waskaweb: controllers model
scm-commit@wald.intevation.org
scm-commit at wald.intevation.org
Sat Sep 5 10:34:21 CEST 2009
Author: frank
Date: 2009-09-05 10:34:20 +0200 (Sat, 05 Sep 2009)
New Revision: 592
Modified:
wasko/branches/1.0/waskaweb/controllers/case.py
wasko/branches/1.0/waskaweb/model/case.py
wasko/branches/1.0/waskaweb/model/phases_factory.py
Log:
Call getData with explicite master_id to avoid side effects on case bundles.
Modified: wasko/branches/1.0/waskaweb/controllers/case.py
===================================================================
--- wasko/branches/1.0/waskaweb/controllers/case.py 2009-09-04 09:26:30 UTC (rev 591)
+++ wasko/branches/1.0/waskaweb/controllers/case.py 2009-09-05 08:34:20 UTC (rev 592)
@@ -270,7 +270,7 @@
elif isinstance(field, RadioNode) \
or isinstance(field, ChoiceNode) :
if fieldname in ('hilfm_1','hilfm_2','hilfm_3'):
- if g.formedTree.getData(fieldname) == -1:
+ if g.formedTree.getData(fieldname, case.getId()) == -1:
fields[fieldname] = '0'
elif fieldname == 'cm_end_art':
pass # Due to a bug in rules/missing fields
Modified: wasko/branches/1.0/waskaweb/model/case.py
===================================================================
--- wasko/branches/1.0/waskaweb/model/case.py 2009-09-04 09:26:30 UTC (rev 591)
+++ wasko/branches/1.0/waskaweb/model/case.py 2009-09-05 08:34:20 UTC (rev 592)
@@ -46,6 +46,7 @@
from waskaweb.lib.xmlexport import exportAsXML
from waskaweb.lib.base import session, g, h, config
import waskaweb.lib.filters as F
+from waskaweb.model import UNKNOWN_DATE
from waskaweb.model.user import UserObject, UserGroupFactory
from waskaweb.model.agencysettings import Agency
from waskaweb.model.repeatgroup import AidList, CREATE_RG_BILDEN_DS,CREATE_RG_LEBEN_DS, CREATE_RG_QUALI_DS, CREATE_RG_BERUF_DS
@@ -182,12 +183,12 @@
def getCases(self, filter=None):
list = []
- factory = CaseFactory()
if filter:
cases = [id for id in self.case_list if id not in filter]
else:
cases = self.case_list
for id in cases:
+ factory = CaseFactory()
list.append(factory.loadById(id))
return list
@@ -386,6 +387,7 @@
case.first_name = unicode(str(result.get('vorname_1', '')), 'utf-8')
case.knr = unicode(str(result.get('kundennummer', '')), 'utf-8')
case.first_meeting = result.get('erstgespraech')
+ case.cm_end = result.get('datum_cm_ende')
case.editor = result.get('bearbeiter_id', None)
case.state = State(id)
return case
@@ -778,6 +780,7 @@
self.knr = None
self.state = None
self.first_meeting = None
+ self.cm_end = None
self.privacy_statement = False
self.street = None
@@ -834,10 +837,19 @@
return self.first_name
def isYoungerThan(self, mydate):
+ '''Return True if case was active relative to mydate.
+
+ Case either started or finished after mdate, or no end date set.
+ '''
y,m,d = mydate.split('-')
if self.first_meeting:
- older = self.first_meeting > date(int(y), int(m), int(d))
- return older
+ if self.first_meeting > date(int(y), int(m), int(d)):
+ return True
+ elif self.cm_end and (self.cm_end <= date(int(y), int(m), int(d))
+ and self.cm_end != UNKNOWN_DATE):
+ return False
+ else:
+ return True
return True
def save():
@@ -853,6 +865,7 @@
self.standin = None
self.state = None
self.first_meeting = None
+ self.cm_end = None
self.digest = None
self.page = None
@@ -905,6 +918,7 @@
session.knr = self.knr
session.state = self.state
session.first_meeting = self.first_meeting
+ session.cm_end = self.cm_end
privacy_statement = self.getPrivacyStatement()
session.privacy_statement = privacy_statement.isSigned()
return session
@@ -1076,13 +1090,22 @@
self.getState().setState(1)
def getFirstMeeting(self):
- return self.first_name
+ return self.first_meeting
def isYoungerThan(self, mydate):
+ '''Return True if case was active relative to mydate.
+
+ Case either started or finished after mdate, or no end date set.
+ '''
y,m,d = mydate.split('-')
if self.first_meeting:
- older = self.first_meeting > date(int(y), int(m), int(d))
- return older
+ if self.first_meeting > date(int(y), int(m), int(d)):
+ return True
+ elif self.cm_end and (self.cm_end <= date(int(y), int(m), int(d))
+ and self.cm_end != UNKNOWN_DATE):
+ return False
+ else:
+ return True
return True
class State(object):
@@ -1210,7 +1233,7 @@
#case = CaseFactory().loadById(self.master_id) # Ugly we need to load the case here :(
cf = self.getPhase()
rf = RequiredFields(g.formedTree)
- p_pairs = rf.phases_pairs(cf)
+ p_pairs = rf.phases_pairs(cf, master_id = self.master_id)
for pair in p_pairs:
p1, p2 = pair.getStart(), pair.getEnd()
@@ -1236,7 +1259,7 @@
Else False.'''
cf = self.getPhase()
rf = RequiredFields(g.formedTree)
- current_phase = rf.currentPhase(cf)
+ current_phase = rf.currentPhase(cf, master_id = self.master_id)
# WASKO requires a special handling of CM_START:
# - if CM_START is completed and
@@ -1244,9 +1267,9 @@
# - datum_cm_ende is set.
if cf == CM_START:
if current_phase.isRecursiveComplete() \
- and g.formedTree.getData('cm_end_art') == 3 \
- and g.formedTree.getData('datum_cm_ende') \
- and str(g.formedTree.getData('datum_cm_ende')) != '0001-01-01':
+ and g.formedTree.getData('cm_end_art', self.master_id) == 3 \
+ and g.formedTree.getData('datum_cm_ende', self.master_id) \
+ and str(g.formedTree.getData('datum_cm_ende', self.master_id)) != '0001-01-01':
return True
else:
return False
Modified: wasko/branches/1.0/waskaweb/model/phases_factory.py
===================================================================
--- wasko/branches/1.0/waskaweb/model/phases_factory.py 2009-09-04 09:26:30 UTC (rev 591)
+++ wasko/branches/1.0/waskaweb/model/phases_factory.py 2009-09-05 08:34:20 UTC (rev 592)
@@ -80,6 +80,7 @@
self.rule_eval_cache = {}
self.var_eval_cache = {}
+
def getPhaseTime(self, phase):
try:
return self.phase_times[phase]
@@ -95,10 +96,10 @@
return None
return pt
- def isPhaseComplete(self, phase):
- return not bool(self.missingFields(phase))
+ def isPhaseComplete(self, phase, master_id = None):
+ return not bool(self.missingFields(phase, master_id))
-# def missingFields(self, phase):
+# def missingFields(self, phase, master_id):
# outfile = None
# try:
# outfile = open("/tmp/phases.txt", "a")
@@ -108,8 +109,7 @@
# try: outfile.close()
# except: pass
- #def missingFieldsX(self, phase, outfile):
- def missingFields(self, phase):
+ def missingFields(self, phase, master_id = None):
#print >> outfile, "\nEvaluating phase '%s' -------------------------------" % phase
@@ -154,7 +154,7 @@
except KeyError:
expr = rule.getExpr()
deps = expr.getDependencies()
- params = dict((v, getData(v)) for v in deps)
+ params = dict((v, getData(v, master_id)) for v in deps)
try:
result = expr.evaluate(params)
except:
@@ -171,14 +171,16 @@
#print >> outfile, "missing: %s " % ', '.join([x.getName() for x in missing])
return missing
- def getLinkListForPhase(self, phase, navigation=None, link=None):
+ def getLinkListForPhase(self, phase, navigation=None, link=None,
+ master_id = None):
if not navigation and not link: return u""
all_vars = self.formed.getPhaseVars(phase)
if not all_vars: return u""
- missing_set = set([x.getName() for x in self.missingFields(phase)])
+ missing_set = set([x.getName() for x in
+ self.missingFields(phase, master_id = master_id)])
pages, used_pages = [], {}
@@ -252,7 +254,8 @@
return u"".join(out)
- def phases_pairs(self, current_phase, navigation=None, link=None):
+ def phases_pairs(
+ self, current_phase, navigation=None, link=None, master_id = None):
pairs = []
@@ -263,9 +266,9 @@
cur_phase = Phase(
current_phase,
True,
- self.isPhaseComplete(symbol),
+ self.isPhaseComplete(symbol, master_id),
self.getPhaseTime(symbol),
- self.getLinkListForPhase(symbol, navigation, link))
+ self.getLinkListForPhase(symbol, navigation, link, master_id))
for p1, p2, description in PAIRS:
@@ -274,9 +277,9 @@
start = Phase(
p1,
p1 == current_phase,
- self.isPhaseComplete(symbol),
+ self.isPhaseComplete(symbol, master_id),
self.getPhaseTime(symbol),
- self.getLinkListForPhase(symbol, navigation, link))
+ self.getLinkListForPhase(symbol, navigation, link, master_id))
all[p1] = start
@@ -285,9 +288,9 @@
ende = Phase(
p2,
p2 == current_phase,
- self.isPhaseComplete(symbol),
+ self.isPhaseComplete(symbol, master_id),
self.getPhaseTime(symbol),
- self.getLinkListForPhase(symbol, navigation, link))
+ self.getLinkListForPhase(symbol, navigation, link, master_id))
all[p2] = ende
@@ -308,15 +311,16 @@
return pairs
- def currentPhase(required_fields, current_phase):
+ def currentPhase(required_fields, current_phase, master_id = None):
symbol = phase_symbol(current_phase)
cur_phase = Phase(
current_phase,
True,
- required_fields.isPhaseComplete(symbol),
+ required_fields.isPhaseComplete(symbol, master_id),
required_fields.getPhaseTime(symbol),
- required_fields.getLinkListForPhase(symbol, None, None))
+ required_fields.getLinkListForPhase(symbol, None, None,
+ master_id))
return cur_phase
# vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8:
More information about the Mpuls-commits
mailing list