[Mpuls-commits] r1835 - wasko/branches/2.0/mpulsweb/model
scm-commit@wald.intevation.org
scm-commit at wald.intevation.org
Fri Feb 26 10:02:43 CET 2010
Author: torsten
Date: 2010-02-26 10:02:42 +0100 (Fri, 26 Feb 2010)
New Revision: 1835
Modified:
wasko/branches/2.0/mpulsweb/model/phase.py
Log:
* mpulsweb/model/phase.py: Implement some code to check if a case can
be anonymized.
Modified: wasko/branches/2.0/mpulsweb/model/phase.py
===================================================================
--- wasko/branches/2.0/mpulsweb/model/phase.py 2010-02-26 09:00:51 UTC (rev 1834)
+++ wasko/branches/2.0/mpulsweb/model/phase.py 2010-02-26 09:02:42 UTC (rev 1835)
@@ -26,8 +26,8 @@
it = factory.loadInstanceTreeByIdentifier(id)
for p in g.mpuls_config.get('phases', 'phases'):
desc = g.mpuls_config.get('phases', 'description')[0].get(p)
- start = PhasePart(g.mpuls_config.get('phases', 'pairs')[0].get(p)[0], it)
- end = PhasePart(g.mpuls_config.get('phases', 'pairs')[0].get(p)[1], it)
+ start = StartPhasePart(g.mpuls_config.get('phases', 'pairs')[0].get(p)[0],p, it)
+ end = EndPhasePart(g.mpuls_config.get('phases', 'pairs')[0].get(p)[1],p, it)
self.phases.append(Phase(start, end, desc))
return self.phases
@@ -35,11 +35,19 @@
def get_current_phase_id(self):
'''Returns id of current active phasepart'''
+ p = self.get_current_phase()
+ if p:
+ return p.id
+ else:
+ return "-1"
+
+ def get_current_phase(self):
+ '''Returns id of current active phasepart'''
for phase in self:
p1, p2 = phase.getStart(), phase.getEnd()
- if p1.is_active(): return p1.id
- if p2.is_active(): return p2.id
- return "-1" # No phase set
+ if p1.is_active(): return p1
+ if p2.is_active(): return p2
+ return None
def is_valid(self):
'''Returns true if all phaseparts up to the current phase are ok. This
@@ -85,11 +93,12 @@
return self.description
def isRunning(self):
- return self.start.isRunning() or self.end.isRunning()
+ return self.start.is_active()
class PhasePart:
- def __init__(self, id, it):
+ def __init__(self, id, phase, it):
self.id = id
+ self.phase = phase
self.active = False
self.date = None
self.fields = []
@@ -134,11 +143,21 @@
def is_active(self):
return self.active
+ def is_anonymizable(self):
+ return self.id not in g.mpuls_config.get('phases', 'notanonymizable')
+
def is_ok(self):
for field in self.fields:
if not field.is_ok(): return False
return True
+class StartPhasePart(PhasePart):
+ pass
+
+class EndPhasePart(PhasePart):
+ pass
+ pass
+
class Field:
def __init__(self, name, page, rules, it):
self.name = name
More information about the Mpuls-commits
mailing list