[Mpuls-commits] r690 - in waska/trunk: . formed waskaweb/controllers waskaweb/lib waskaweb/model
scm-commit@wald.intevation.org
scm-commit at wald.intevation.org
Mon Nov 16 10:15:53 CET 2009
Author: torsten
Date: 2009-11-16 10:15:51 +0100 (Mon, 16 Nov 2009)
New Revision: 690
Modified:
waska/trunk/ChangeLog.txt
waska/trunk/formed/formedtree_web.xml
waska/trunk/waskaweb/controllers/case.py
waska/trunk/waskaweb/lib/renderer.py
waska/trunk/waskaweb/model/case.py
waska/trunk/waskaweb/model/phases_factory.py
Log:
Conditional required fields
Modified: waska/trunk/ChangeLog.txt
===================================================================
--- waska/trunk/ChangeLog.txt 2009-11-13 17:12:21 UTC (rev 689)
+++ waska/trunk/ChangeLog.txt 2009-11-16 09:15:51 UTC (rev 690)
@@ -1,3 +1,14 @@
+2009-11-16 Torsten Irlaender <torsten.irlaender at intevation.de>
+
+ Conditional required fields
+
+ * waskaweb/model/phases_factory.py,
+ waskaweb/model/case.py,
+ waskaweb/controllers/case.py,
+ waskaweb/lib/renderer.py,
+ formed/formedtree_web.xml: Hardcoded some checks if a field is a
+ required fields based on user data
+
2009-11-13 Sascha L. Teichmann <sascha.teichmann at intevation.de>
* waskaweb/lib/xmlimport.py: Re-generated type checking dictionaries
Modified: waska/trunk/formed/formedtree_web.xml
===================================================================
--- waska/trunk/formed/formedtree_web.xml 2009-11-13 17:12:21 UTC (rev 689)
+++ waska/trunk/formed/formedtree_web.xml 2009-11-16 09:15:51 UTC (rev 690)
@@ -60,7 +60,7 @@
</group>
</choice>
<text description="Kundennummer bei der Kompetenzagentur" formularname="Kundennummer" function="suppress_value" maxlength="100" modes="-mode1.1anon" name="kundennummer" size="50" target="g"/>
- <conditional expr="$zugang_kompetenzagentur 10 !=" name="conditional-0" target="h">
+ <conditional expr="$zugang_kompetenzagentur 10 ==" name="conditional-0" target="h">
<group containers="a,b,c,d" description="Übergangsprognose" name="group-6" target="h">
<choice description="Die Schülerin / der Schüler befindet sich im letzten Schulbesuchsjahr der allgemeinbildenen Schule" flags="evaluation;required:clearing_start" name="letzte_jahr_allg_schule" size="1" target="a">
<bool checked="true" description="Keine Angabe" name="keineangabe" value="-1"/>
Modified: waska/trunk/waskaweb/controllers/case.py
===================================================================
--- waska/trunk/waskaweb/controllers/case.py 2009-11-13 17:12:21 UTC (rev 689)
+++ waska/trunk/waskaweb/controllers/case.py 2009-11-16 09:15:51 UTC (rev 690)
@@ -732,6 +732,16 @@
def phase(self, id):
id = self._checkInt(id)
case = self._loadCase(id)
+
+ # Check if the cm can be started
+ v1 = case.letzteschul
+ v2 = case.prognose
+ v3 = case.zugang
+ c.disable_cm = False
+ c.zugang = v3
+ if v3 == 10 and (v1 == 0 or (v1 == 1 and v2 == 0)):
+ c.disable_cm = True
+
fields = case.getRequiredFields()
phase = case.getState().getPhase()
@@ -739,13 +749,6 @@
session_case = session.get('case')
- # Check if the cm can be started
- v1 = case.letzteschul
- v2 = case.prognose
- c.disable_cm = False
- if v1 == 0 or (v1 == 1 and v2 == 0):
- c.disable_cm = True
-
mode = session_case and session_case.getMode() or "show"
link = lambda ti: '"/case/%s/%d/%s"' % (mode, ti.realId(id), ti.key)
Modified: waska/trunk/waskaweb/lib/renderer.py
===================================================================
--- waska/trunk/waskaweb/lib/renderer.py 2009-11-13 17:12:21 UTC (rev 689)
+++ waska/trunk/waskaweb/lib/renderer.py 2009-11-16 09:15:51 UTC (rev 690)
@@ -208,6 +208,26 @@
ok = False
return ok
+ def getHelp(self, dataID):
+ if not self.help: return ''
+
+ out = []
+
+ if self.help.hasAnnotations(dataID):
+ if dataID in ['prognose_liegt_vor', 'letzte_jahr_allg_schule']:
+ if self.getData('zugang_kompetenzagentur') == '10':
+ out.append(REQUIRED % h.url_for('required', help_id=escape(dataID)))
+ else:
+ out.append(REQUIRED % h.url_for('required', help_id=escape(dataID)))
+
+ if self.help.hasAnnotations(dataID, ('evaluation',)):
+ out.append(EVALUATION % h.url_for('showevalhelp', help_id=escape(dataID)))
+
+ if self.help.hasHelp(dataID):
+ out.append(HELP % h.url_for('formhelp', help_id=escape(dataID)))
+
+ return ''.join(out)
+
class Text:
def __init__(self, txt):
self.txt = txt
@@ -361,7 +381,8 @@
# Render Error dialog
v1 = self.formdata.getData('letzte_jahr_allg_schule')
v2 = self.formdata.getData('prognose_liegt_vor')
- if v1 == '0' or (v1 == '1' and v2 == '0'):
+ v3 = self.formdata.getData('zugang_kompetenzagentur')
+ if v3 == '10' and (v1 == '0' or (v1 == '1' and v2 == '0')):
out.append(DIALOG_SCHUELER1)
if not self.ro_mode:
out.append('<form id="waska_form" action="')
Modified: waska/trunk/waskaweb/model/case.py
===================================================================
--- waska/trunk/waskaweb/model/case.py 2009-11-13 17:12:21 UTC (rev 689)
+++ waska/trunk/waskaweb/model/case.py 2009-11-16 09:15:51 UTC (rev 690)
@@ -119,7 +119,7 @@
FROM master_tbl_view WHERE id = %(id)s
"""
-LOAD_CASE_SQL = """SELECT name_1, vorname_1, bearbeiter_id, kundennummer, erstgespraech, beendigung_5, letzte_jahr_allg_schule, prognose_liegt_vor from master_tbl_view WHERE id = %(id)s"""
+LOAD_CASE_SQL = """SELECT name_1, vorname_1, bearbeiter_id, kundennummer, erstgespraech, beendigung_5, zugang_kompetenzagentur, letzte_jahr_allg_schule, prognose_liegt_vor from master_tbl_view WHERE id = %(id)s"""
DELETE_CASE_SQL = """select delete_master_ds(%(id)s)"""
CREATE_CASE_SQL = """SELECT create_master_ds(%(uuid)s)"""
@@ -401,6 +401,7 @@
case.state = State(id)
# Hack. These values are used to determine if the phase of CM can be startet
+ case.zugang = result.get('zugang_kompetenzagentur')
case.letzteschul = result.get('letzte_jahr_allg_schule')
case.prognose = result.get('prognose_liegt_vor')
Modified: waska/trunk/waskaweb/model/phases_factory.py
===================================================================
--- waska/trunk/waskaweb/model/phases_factory.py 2009-11-13 17:12:21 UTC (rev 689)
+++ waska/trunk/waskaweb/model/phases_factory.py 2009-11-16 09:15:51 UTC (rev 690)
@@ -28,6 +28,7 @@
# Sascha L. Teichmann <sascha.teichmann at intevation.de>
#
+from waskaweb.lib.base import *
from waskaweb.model.phases import *
from waskaweb.model.phase_transition import *
@@ -97,7 +98,13 @@
kind, phase = p[0], p[1]
if kind == "required":
for p in [p.strip() for p in phase.split(',')]:
- if p: phases.setdefault(p, []).append([nc, None])
+ if p:
+ # Filter out some required fields based on userdata
+ if c.zugang != 10 and nc.getName() in ['prognose_liegt_vor', \
+ 'letzte_jahr_allg_schule']:
+ continue
+ else:
+ phases.setdefault(p, []).append([nc, None])
elif kind == "time":
for p in [p.strip() for p in phase.split(',')]:
if p: times.setdefault(p, []).append([nc, None])
@@ -119,6 +126,7 @@
for v in phases.itervalues():
v.sort(cmp=lambda a, b: cmp(description(a[0]), description(b[0])))
+
self.phases = phases
self.times = times
return phases
More information about the Mpuls-commits
mailing list