Skip to content

Commit

Permalink
rearrange for readability
Browse files Browse the repository at this point in the history
  • Loading branch information
davisagli committed Jan 5, 2012
1 parent f900bdc commit fa074d8
Showing 1 changed file with 14 additions and 16 deletions.
30 changes: 14 additions & 16 deletions collective/z3cform/wizard/wizard.py
Original file line number Diff line number Diff line change
Expand Up @@ -253,25 +253,23 @@ def onFirstStep(self):
condition=lambda form:not form.onFirstStep)
def handleBack(self, action):
messages = IStatusMessage(self.request)
data, errors = self.currentStep.extractData()

if self.validate_back == False:
# If 'validate_back' is False, skip the error handling
# and abandon the data for this Step
self.updateCurrentStep(self.currentIndex - 1)
self.updateActions()
else:

if self.validate_back:
# if true, only allow navigating back if the current
# step validates
data, errors = self.currentStep.extractData()
if errors:
self.status = self.formErrorsMessage
messages.addStatusMessage(self.status, type="error")
else:
self.currentStep.applyChanges(data)
self.updateCurrentStep(self.currentIndex - 1)

# Back can change the conditions for the finish button,
# so we need to reconstruct the button actions, since we
# do not redirect.
self.updateActions()
return
self.currentStep.applyChanges(data)

self.updateCurrentStep(self.currentIndex - 1)

# Back can change the conditions for the finish button,
# so we need to reconstruct the button actions, since we
# do not redirect.
self.updateActions()

def showClear(self):
values = [v for v in self.session.values() if isinstance(v, dict)]
Expand Down

0 comments on commit fa074d8

Please sign in to comment.