[Mpuls-commits] r3335 - in wasko/trunk: . waskoweb/controllers
scm-commit@wald.intevation.org
scm-commit at wald.intevation.org
Fri Aug 6 11:41:40 CEST 2010
Author: roland
Date: 2010-08-06 11:41:39 +0200 (Fri, 06 Aug 2010)
New Revision: 3335
Modified:
wasko/trunk/ChangeLog
wasko/trunk/wasko.json
wasko/trunk/waskoweb/controllers/formularpage.py
Log:
Issue930: ported automatic phase changes
Modified: wasko/trunk/ChangeLog
===================================================================
--- wasko/trunk/ChangeLog 2010-08-06 07:08:26 UTC (rev 3334)
+++ wasko/trunk/ChangeLog 2010-08-06 09:41:39 UTC (rev 3335)
@@ -1,3 +1,8 @@
+2010-08-02 Roland Geider <roland.geider at intevation.de>
+
+ * waskoweb/controllers/formularpage.py: Issue930: ported automatic
+ phase changes to overwritten wasko controller
+
2010-08-03 Torsten Irländer <torsten.irlaender at intevation.de>
Issue664:
Modified: wasko/trunk/wasko.json
===================================================================
--- wasko/trunk/wasko.json 2010-08-06 07:08:26 UTC (rev 3334)
+++ wasko/trunk/wasko.json 2010-08-06 09:41:39 UTC (rev 3335)
@@ -19,6 +19,7 @@
},
"phases": {
"phases": ["0","1","2"],
+ "changemode" : 1,
"description": [{
"-1": "Unbekannt",
"0": "Eingangsdokumentation",
Modified: wasko/trunk/waskoweb/controllers/formularpage.py
===================================================================
--- wasko/trunk/waskoweb/controllers/formularpage.py 2010-08-06 07:08:26 UTC (rev 3334)
+++ wasko/trunk/waskoweb/controllers/formularpage.py 2010-08-06 09:41:39 UTC (rev 3335)
@@ -44,19 +44,26 @@
from mpulsweb.lib.security import checkRole
-from formed.instance.backends.postgres import DBFactory as InstanceFactory
+from formed.instance.backends.postgres import DBFactory as InstanceFactory, \
+ DBRepeatInstanceNode as RepeatInstanceNode
from formed.instance.tree import SetDataException, RepeatInstanceContainerNode
+from mpulsweb.lib.translation import _
from mpulsweb.lib.security import checkRole
from mpulsweb.lib.db import PostgresDBInterface
from mpulsweb.lib.navigation import mark_folderopen
from mpulsweb.lib.base import BaseController, render
from mpulsweb.lib.renderer import ViewRenderer, RepeatGroupRenderer, \
- ErrorRenderer, apply_hidden_booleans
+ ErrorRenderer, apply_hidden_booleans, get_child_num
from mpulsweb.lib.helpers import url_for, dd_mm_YYYY as format_date
+from mpulsweb.model.phase import PhaseFactory, \
+ PC_MANUAL, PC_HALFAUTO, PC_FULLAUTO, \
+ DIALOG_FULLAUTOMATIC_CHANGE_TITLE, DIALOG_FULLAUTOMATIC_CHANGE_TEXT, \
+ DIALOG_HALFAUTOMATIC_CHANGE_TITLE, DIALOG_HALFAUTOMATIC_CHANGE_TEXT
+
from waskoweb.model.agencysettings import Agency
class FormularpageController(FormularpageController):
@@ -130,5 +137,45 @@
#error_status(_('Error while saving data'))
session['uncommited_fields'] = instance_tree.commit()
session.save()
+
+ # Check requried fields of the case and set phase
+ changemode = g.mpuls_config.get('phases', 'changemode')
+ if changemode != PC_MANUAL:
+ phases = PhaseFactory().load(session['case'].id)
+ log.debug("current phase: %s" % phases.get_current_phase_id())
+ log.debug("max phase? %s" % phases.get_max_phase_id())
+ current_phase = phases.get_current_phase_id()
+ log.debug(g.mpuls_config.get('phases', 'description'))
+ reachable_phase = phases.get_max_phase_id()
+ if current_phase != reachable_phase:
+ cpd = phases.get_phase(current_phase).getDescription()
+ rpd = phases.get_phase(reachable_phase).getDescription()
+ if changemode == PC_FULLAUTO:
+ log.debug("fullautomatic phase change!")
+ #load case and set phase
+ case = g.case_factory.loadById(session['case'].id)
+ case.getState().setPhase(reachable_phase)
+ # build dialog
+ c.dialog_title = DIALOG_FULLAUTOMATIC_CHANGE_TITLE
+ c.dialog_text = DIALOG_FULLAUTOMATIC_CHANGE_TEXT \
+ % (cpd, rpd)
+ c.url_ok = url_for(controller="formularpage",
+ action="select",
+ id=page_id)
+ return render('/phase/dialogs/success_fullautomatic_set_phase.mako')
+ else:
+ log.debug("halfautomatic phase change!")
+ # build dialog
+ c.dialog_title = DIALOG_HALFAUTOMATIC_CHANGE_TITLE
+ c.dialog_text = DIALOG_HALFAUTOMATIC_CHANGE_TEXT \
+ % (cpd, rpd)
+ c.url_ok = url_for(controller="phase",
+ action="setPhase",
+ id=session['case'].id,
+ value=reachable_phase)
+ c.url_no = url_for(controller="formularpage",
+ action="select",
+ id=page_id)
+ return render('/phase/dialogs/success_halfautomatic_set_phase.mako')
return self.select(page_id)
\ No newline at end of file
More information about the Mpuls-commits
mailing list