[Mpuls-commits] r3358 - wasko/trunk/waskoweb/controllers
scm-commit@wald.intevation.org
scm-commit at wald.intevation.org
Tue Aug 10 15:34:23 CEST 2010
Author: roland
Date: 2010-08-10 15:34:22 +0200 (Tue, 10 Aug 2010)
New Revision: 3358
Modified:
wasko/trunk/waskoweb/controllers/formularpage.py
Log:
calculate the maximum cm length after saving the data
Modified: wasko/trunk/waskoweb/controllers/formularpage.py
===================================================================
--- wasko/trunk/waskoweb/controllers/formularpage.py 2010-08-10 13:20:39 UTC (rev 3357)
+++ wasko/trunk/waskoweb/controllers/formularpage.py 2010-08-10 13:34:22 UTC (rev 3358)
@@ -81,7 +81,75 @@
# Save the request parameters for later use
form_result = convert2dic(request.params)
+ """
+ Generate the evaluation ID
+ """
+ factory = InstanceFactory(g.formedTree, PostgresDBInterface())
+ instance_tree = factory.loadInstanceTreeByIdentifier(
+ session['case'].id,
+ session.get('uncommited_fields'))
+ page_id = request.params['page']
+ try:
+
+ apply_hidden_booleans(form_result)
+
+ # Special logic for the Evaluation-ID
+ if request.params['page'].split(':')[0] == 'page-2':
+
+ # Reset the evaluation number is the young adult does not want
+ # to participate in the survey or does not want his personal
+ # data to be used
+ if form_result['teilnahme_evaluation:%s' % case_id] in \
+ [u'-1', u'1', u'3', u'4', u'5']:
+ form_result['evaluation_nummer:%s' % case_id] = u''
+
+ # The evaluation_nummer field might be grayed out, so it won't
+ # be in the sent fields dictionary
+ elif 'evaluation_nummer:%s' % case_id not in form_result:
+ agency = Agency()
+ # Generate the ID (we do not check for uniqueness). It is
+ # created from the evaluation abbreviation (agency wide) and
+ # a manually entered number or sequence
+ form_result['evaluation_nummer:%s' % case_id] = \
+ u"%s-(bitte ergaenzen)" % (agency.getEvaluationId())
+
+ instance_tree.setData(form_result)
+ session['uncommited_fields'] = instance_tree.commit()
+ session.save()
+
+ # How to proceed after saving the data?
+ for param in request.params:
+ if param.startswith('add_rg') and not param.endswith(('x','y')):
+ if param == 'add_rg':
+ redirect_to(controller='/repeatgroup', action="new",
+ id=request.params.get('add_rg'))
+ else:
+ redirect_to(controller='/repeatgroup', action="new",
+ id=param.split('|')[1])
+ elif param.startswith('del_rg') and not param.endswith(('x','y')):
+ redirect_to(controller='/repeatgroup', action="delete",
+ id=param.split('|')[1])
+
+ if request.params.has_key('savenext'):
+ page_id = session['navigation.tree'].getTreeItem(page_id).nextKey().key
+
+ # Check consistence of case and retag
+ if g.mpuls_config.is_enabled ('case-module', 'checktags'):
+ # TODO: Implement application based tagging
+ pass
+ #log.debug('Tagging case: %s' % session['case'].id)
+
+ except SetDataException, err:
+ # Do nothing other than setting the status message. In the future the
+ # exception can be used to fill out the form again with htmlfill,
+ # which will clean up the renderer code a lot! But this is for the
+ # future
+ #error_status(_('Error while saving data'))
+ session['uncommited_fields'] = instance_tree.commit()
+ session.save()
+
+
"""
Calculate the total length of the CM, including extensions and create
a new appointment if the length is longer than a certain limit
@@ -168,74 +236,8 @@
appointment.setData(appointment_data)
appointment.store()
+
"""
- Generate the evaluation ID
- """
- factory = InstanceFactory(g.formedTree, PostgresDBInterface())
- instance_tree = factory.loadInstanceTreeByIdentifier(
- session['case'].id,
- session.get('uncommited_fields'))
- page_id = request.params['page']
- try:
-
- apply_hidden_booleans(form_result)
-
- # Special logic for the Evaluation-ID
- if request.params['page'].split(':')[0] == 'page-2':
-
- # Reset the evaluation number is the young adult does not want
- # to participate in the survey or does not want his personal
- # data to be used
- if form_result['teilnahme_evaluation:%s' % case_id] in \
- [u'-1', u'1', u'3', u'4', u'5']:
- form_result['evaluation_nummer:%s' % case_id] = u''
-
- # The evaluation_nummer field might be grayed out, so it won't
- # be in the sent fields dictionary
- elif 'evaluation_nummer:%s' % case_id not in form_result:
- agency = Agency()
- # Generate the ID (we do not check for uniqueness). It is
- # created from the evaluation abbreviation (agency wide) and
- # a manually entered number or sequence
- form_result['evaluation_nummer:%s' % case_id] = \
- u"%s-(bitte ergaenzen)" % (agency.getEvaluationId())
-
- instance_tree.setData(form_result)
- session['uncommited_fields'] = instance_tree.commit()
- session.save()
-
- # How to proceed after saving the data?
- for param in request.params:
- if param.startswith('add_rg') and not param.endswith(('x','y')):
- if param == 'add_rg':
- redirect_to(controller='/repeatgroup', action="new",
- id=request.params.get('add_rg'))
- else:
- redirect_to(controller='/repeatgroup', action="new",
- id=param.split('|')[1])
- elif param.startswith('del_rg') and not param.endswith(('x','y')):
- redirect_to(controller='/repeatgroup', action="delete",
- id=param.split('|')[1])
-
- if request.params.has_key('savenext'):
- page_id = session['navigation.tree'].getTreeItem(page_id).nextKey().key
-
- # Check consistence of case and retag
- if g.mpuls_config.is_enabled ('case-module', 'checktags'):
- # TODO: Implement application based tagging
- pass
- #log.debug('Tagging case: %s' % session['case'].id)
-
- except SetDataException, err:
- # Do nothing other than setting the status message. In the future the
- # exception can be used to fill out the form again with htmlfill,
- # which will clean up the renderer code a lot! But this is for the
- # future
- #error_status(_('Error while saving data'))
- session['uncommited_fields'] = instance_tree.commit()
- session.save()
-
- """
(Half)Automatic phase change
"""
changemode = g.mpuls_config.get('phases', 'changemode')
More information about the Mpuls-commits
mailing list