[Mpuls-commits] r133 - in waska/trunk: . waskaweb/controllers waskaweb/model
scm-commit@wald.intevation.org
scm-commit at wald.intevation.org
Thu Sep 4 07:37:35 CEST 2008
Author: teichmann
Date: 2008-09-04 07:37:34 +0200 (Thu, 04 Sep 2008)
New Revision: 133
Modified:
waska/trunk/ChangeLog.txt
waska/trunk/waskaweb/controllers/case.py
waska/trunk/waskaweb/model/phase_transition.py
Log:
Set phase
Modified: waska/trunk/ChangeLog.txt
===================================================================
--- waska/trunk/ChangeLog.txt 2008-09-03 16:47:27 UTC (rev 132)
+++ waska/trunk/ChangeLog.txt 2008-09-04 05:37:34 UTC (rev 133)
@@ -1,3 +1,11 @@
+2008-09-04 Sascha L. Teichmann <sascha.teichmann at intevation.de>
+
+ * waskaweb/model/phase_transition.py: add function to map
+ back phase symbol to phase number.
+
+ * waskaweb/controllers/case.py: Set phase. TODO: Mako template
+ for error conditions.
+
2008-09-03 Sascha L. Teichmann <sascha.teichmann at intevation.de>
* waskaweb/model/phase_transition.py: Added missing transition.
Modified: waska/trunk/waskaweb/controllers/case.py
===================================================================
--- waska/trunk/waskaweb/controllers/case.py 2008-09-03 16:47:27 UTC (rev 132)
+++ waska/trunk/waskaweb/controllers/case.py 2008-09-04 05:37:34 UTC (rev 133)
@@ -68,8 +68,9 @@
from waskaweb.model.data import FilteredNodeComponentProxy
from waskaweb.model.logbook import Logbook, LogbookEntry, LogbookEntryChecker
-from waskaweb.model.phases_factory import phases_pairs
-from waskaweb.model.phases import Phase
+from waskaweb.model.phases_factory import phases_pairs
+from waskaweb.model.phases import Phase
+from waskaweb.model.phase_transition import symbol_phase, phase_neighbors
from waskaweb.lib.db import db
from waskaweb.lib.xmlimport import importFromXML
@@ -711,7 +712,31 @@
# Load case and do something on phase
case = factory.loadById(form_result.get('case_id'))
+ new_phase, new_phase_symbol = None, None
+ for new_phase_symbol in request.params.iterkeys():
+ try:
+ new_phase = symbol_phase(new_phase_symbol)
+ break
+ except KeyError:
+ pass
+
+ if new_phase is None:
+ raise Error("Phase nicht gefunden.")
+
+ state = case.getState()
+
+ current_phase = state.getPhase()
+
+ if not phase_neighbors(current_phase, new_phase):
+ raise Error("Phasen sind nicht benachbart.")
+
+ fields = case.getRequiredFields()
+ if not fields.isPhaseComplete(new_phase_symbol):
+ raise Error("Phase ist nicht komplett.")
+
+ state.setPhase(new_phase)
+
# After setting the phase. Show print-dialog
c.success_for = SET_PHASE_NOTIFICATION_SUCCESS
c.success_text = SET_PHASE_NOTIFICATION_TEXT_SUCCESS
Modified: waska/trunk/waskaweb/model/phase_transition.py
===================================================================
--- waska/trunk/waskaweb/model/phase_transition.py 2008-09-03 16:47:27 UTC (rev 132)
+++ waska/trunk/waskaweb/model/phase_transition.py 2008-09-04 05:37:34 UTC (rev 133)
@@ -66,6 +66,11 @@
BERATUNG_ENDE : u"beratung_ende"
}
+SYMBOLS_PHASE = dict([(i[1], i[0]) for i in PHASE_SYMBOLS.iteritems()])
+
+def invert_phase_symbols():
+ return dict()
+
PHASE_SUCCESSORS = {
UNKNOWN : [CLEAR_START],
CLEAR_START : [CLEAR_ENDE],
@@ -84,6 +89,9 @@
def phase_symbol(phase):
return PHASE_SYMBOLS[phase]
+def symbol_phase(symbol):
+ return SYMBOLS_PHASE[symbol]
+
def phase_successors(phase):
try:
return PHASE_SUCCESSORS[phase]
More information about the Mpuls-commits
mailing list