misc: recreate workflow form after submission, to get live items (#35903)

This commit is contained in:
Frédéric Péters 2019-09-20 12:00:14 +02:00
parent e8384beceb
commit 9da3ee9901
1 changed files with 5 additions and 2 deletions

View File

@ -263,16 +263,19 @@ class FormStatusPage(Directory, FormTemplateMixin):
def get_workflow_form(self, user):
submitted_fields = []
form = self.filled.get_workflow_form(user, displayed_fields=submitted_fields)
if form:
form.attrs['data-live-url'] = self.filled.get_url() + 'live'
if form and form.is_submitted():
with get_publisher().substitutions.temporary_feed(self.filled, force_mode='lazy'):
# remove fields that could be required but are not visible
self.filled.evaluate_live_workflow_form(user, form)
get_publisher().substitutions.invalidate_cache()
get_publisher().substitutions.feed(self.filled)
# recreate form to get live data source items
form = self.filled.get_workflow_form(user, displayed_fields=submitted_fields)
for field in submitted_fields:
if not field.is_visible(self.filled.data, self.formdef) and 'f%s' % field.id in form._names:
del form._names['f%s' % field.id]
if form:
form.attrs['data-live-url'] = self.filled.get_url() + 'live'
return form