本文整理汇总了Python中formtools.wizard.views.StepsHelper方法的典型用法代码示例。如果您正苦于以下问题:Python views.StepsHelper方法的具体用法?Python views.StepsHelper怎么用?Python views.StepsHelper使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类formtools.wizard.views
的用法示例。
在下文中一共展示了views.StepsHelper方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: prepare_form
# 需要导入模块: from formtools.wizard import views [as 别名]
# 或者: from formtools.wizard.views import StepsHelper [as 别名]
def prepare_form(self, __):
# init storage and step helper
self.prefix = normalize_name(self.__class__.__name__)
self.storage = get_storage(
self.storage_name, self.prefix, self.request,
getattr(self, 'file_storage', None))
self.steps = StepsHelper(self)
self.wizard_goto_step = False
if self.request.method == 'GET':
self.storage.reset()
self.storage.current_step = self.steps.first
self.admin_view.model_form = self.get_step_form()
else:
# Look for a wizard_goto_step element in the posted data which
# contains a valid step name. If one was found, render the requested
# form. (This makes stepping back a lot easier).
wizard_goto_step = self.request.POST.get('wizard_goto_step', None)
if wizard_goto_step and int(wizard_goto_step) < len(self.get_form_list()):
self.storage.current_step = self.get_form_list(
).keys()[int(wizard_goto_step)]
self.admin_view.model_form = self.get_step_form()
self.wizard_goto_step = True
return
# Check if form was refreshed
management_form = ManagementForm(
self.request.POST, prefix=self.prefix)
if not management_form.is_valid():
raise ValidationError(
'ManagementForm data is missing or has been tampered.')
form_current_step = management_form.cleaned_data['current_step']
if (form_current_step != self.steps.current and
self.storage.current_step is not None):
# form refreshed, change current step
self.storage.current_step = form_current_step
# get the form for the current step
self.admin_view.model_form = self.get_step_form()
示例2: prepare_form
# 需要导入模块: from formtools.wizard import views [as 别名]
# 或者: from formtools.wizard.views import StepsHelper [as 别名]
def prepare_form(self, __):
# init storage and step helper
self.prefix = normalize_name(self.__class__.__name__)
self.storage = get_storage(
self.storage_name, self.prefix, self.request,
getattr(self, 'file_storage', None))
self.steps = StepsHelper(self)
self.wizard_goto_step = False
if self.request.method == 'GET':
self.storage.reset()
self.storage.current_step = self.steps.first
self.admin_view.model_form = self.get_step_form()
else:
# Look for a wizard_goto_step element in the posted data which
# contains a valid step name. If one was found, render the requested
# form. (This makes stepping back a lot easier).
wizard_goto_step = self.request.POST.get('wizard_goto_step', None)
if wizard_goto_step and int(wizard_goto_step) < len(self.get_form_list()):
obj = self.get_form_list().keys()
if six.PY3:
obj = [s for s in obj]
self.storage.current_step = obj[int(wizard_goto_step)]
self.admin_view.model_form = self.get_step_form()
self.wizard_goto_step = True
return
# Check if form was refreshed
management_form = ManagementForm(
self.request.POST, prefix=self.prefix)
if not management_form.is_valid():
raise ValidationError(
'ManagementForm data is missing or has been tampered.')
form_current_step = management_form.cleaned_data['current_step']
if (form_current_step != self.steps.current and
self.storage.current_step is not None):
# form refreshed, change current step
self.storage.current_step = form_current_step
# get the form for the current step
self.admin_view.model_form = self.get_step_form()
示例3: prepare_form
# 需要导入模块: from formtools.wizard import views [as 别名]
# 或者: from formtools.wizard.views import StepsHelper [as 别名]
def prepare_form(self, __):
# init storage and step helper
self.prefix = normalize_name(self.__class__.__name__)
self.storage = get_storage(
self.storage_name, self.prefix, self.request,
getattr(self, 'file_storage', None))
self.steps = StepsHelper(self)
self.wizard_goto_step = False
if self.request.method == 'GET':
self.storage.reset()
self.storage.current_step = self.steps.first
self.admin_view.model_form = self.get_step_form()
else:
# Look for a wizard_goto_step element in the posted data which
# contains a valid step name. If one was found, render the requested
# form. (This makes stepping back a lot easier).
wizard_goto_step = self.request.POST.get('wizard_goto_step', None)
if wizard_goto_step and int(wizard_goto_step) < len(self.get_form_list()):
obj = self.get_form_list().keys()
obj = [s for s in obj]
self.storage.current_step = obj[int(wizard_goto_step)]
self.admin_view.model_form = self.get_step_form()
self.wizard_goto_step = True
return
# Check if form was refreshed
management_form = ManagementForm(
self.request.POST, prefix=self.prefix)
if not management_form.is_valid():
raise ValidationError(
'ManagementForm data is missing or has been tampered.')
form_current_step = management_form.cleaned_data['current_step']
if (form_current_step != self.steps.current and
self.storage.current_step is not None):
# form refreshed, change current step
self.storage.current_step = form_current_step
# get the form for the current step
self.admin_view.model_form = self.get_step_form()
示例4: prepare_form
# 需要导入模块: from formtools.wizard import views [as 别名]
# 或者: from formtools.wizard.views import StepsHelper [as 别名]
def prepare_form(self, __):
# init storage and step helper
self.prefix = normalize_name(self.__class__.__name__)
self.storage = get_storage(
self.storage_name, self.prefix, self.request,
getattr(self, 'file_storage', None))
self.steps = StepsHelper(self)
self.wizard_goto_step = False
if self.request.method == 'GET':
self.storage.reset()
self.storage.current_step = self.steps.first
self.admin_view.model_form = self.get_step_form()
else:
# Look for a wizard_goto_step element in the posted data which
# contains a valid step name. If one was found, render the requested
# form. (This makes stepping back a lot easier).
wizard_goto_step = self.request.POST.get('wizard_goto_step', None)
if wizard_goto_step and int(wizard_goto_step) < len(self.get_form_list()):
self.storage.current_step = self.get_form_list(
).keys()[int(wizard_goto_step)]
self.admin_view.model_form = self.get_step_form()
self.wizard_goto_step = True
return
# Check if form was refreshed
management_form = ManagementForm(
self.request.POST, prefix=self.prefix)
if not management_form.is_valid():
raise ValidationError(
'ManagementForm data is missing or has been tampered.')
form_current_step = management_form.cleaned_data['current_step']
if (form_current_step != self.steps.current and
self.storage.current_step is not None):
# form refreshed, change current step
self.storage.current_step = form_current_step
# get the form for the current step
self.admin_view.model_form = self.get_step_form()