forms: include workflow forms field medias (#29349)

This commit is contained in:
Frédéric Péters 2018-12-26 12:16:03 +01:00
parent 90e0fa5334
commit 9a04369bb7
4 changed files with 11 additions and 4 deletions

View File

@ -3478,6 +3478,7 @@ def test_formdata_form_file_download(pub):
resp = resp.follow()
assert 'The form has been recorded' in resp.body
assert 'qommon.fileupload.js' in resp.body
resp.forms[0]['f1$file'] = Upload('test.txt', 'foobar', 'text/plain')
resp = resp.forms[0].submit('submit')

View File

@ -250,6 +250,9 @@ class FormStatusPage(Directory, FormTemplateMixin):
response.content_type = 'text/plain'
return "Your browser should redirect you"
if form:
form.add_media()
get_response().add_javascript(['jquery.js', 'qommon.forms.js', 'qommon.map.js'])
self.html_top(self.formdef.name)
context = {

View File

@ -397,6 +397,11 @@ class Form(QuixoteForm):
r += htmltext('</fieldset>')
return r.getvalue()
def add_media(self):
for widget in self.get_all_widgets():
if hasattr(widget, 'add_media'):
widget.add_media()
class HtmlWidget(object):
error = None

View File

@ -425,10 +425,8 @@ class QommonTemplateResponse(object):
def add_media(self):
if 'form' in self.context:
# run add_media on all widgets so we get them in the page <head>
for widget in self.context['form'].get_all_widgets():
if hasattr(widget, 'add_media'):
widget.add_media()
# run add_media so we get them in the page <head>
self.context['form'].add_media()
class TemplateError(Exception):