Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def get_steps(self, request=None):
if not hasattr(self, 'steps'):
steps = Steps(self, request=request)
if request is None:
return steps
self.steps = steps
return self.steps
class CoderedStep(Step):
def get_markups_and_bound_fields(self, form):
for struct_child in self.form_fields:
block = struct_child.block
if isinstance(block, FormFieldBlock):
struct_value = struct_child.value
field_name = block.get_slug(struct_value)
yield form[field_name], 'field', struct_child
else:
yield mark_safe(struct_child), 'markup'
class CoderedSteps(Steps):
def __init__(self, page, request=None):
self.page = page
# TODO: Make it possible to change the `form_fields` attribute.
self.form_fields = page.form_fields
self.request = request
has_steps = any(isinstance(struct_child.block, FormStepBlock)
for struct_child in self.form_fields)
if has_steps:
steps = [CoderedStep(self, i, form_field)
for i, form_field in enumerate(self.form_fields)]
else:
steps = [CoderedStep(self, 0, self.form_fields)]
super(Steps, self).__init__(steps)
def __init__(self, page, request=None):
self.page = page
# TODO: Make it possible to change the `form_fields` attribute.
self.form_fields = page.form_fields
self.request = request
has_steps = any(isinstance(struct_child.block, FormStepBlock)
for struct_child in self.form_fields)
if has_steps:
steps = [CoderedStep(self, i, form_field)
for i, form_field in enumerate(self.form_fields)]
else:
steps = [CoderedStep(self, 0, self.form_fields)]
super(Steps, self).__init__(steps)