forms: include workflow forms field medias (#29349)
This commit is contained in:
parent
90e0fa5334
commit
9a04369bb7
|
@ -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')
|
||||
|
||||
|
|
|
@ -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 = {
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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):
|
||||
|
|
Loading…
Reference in New Issue