backoffice: remove thumbnail references for file fields in tables (#31134)
This commit is contained in:
parent
3df85143c6
commit
2b14b99f74
|
@ -562,6 +562,23 @@ def test_backoffice_submission_agent_column(pub):
|
|||
assert len(resp.body.splitlines()) == 18 # 17 + header line
|
||||
assert resp.body.count(',agent,') == 17
|
||||
|
||||
def test_backoffice_image_column(pub):
|
||||
create_superuser(pub)
|
||||
create_environment(pub)
|
||||
formdef = FormDef.get_by_urlname('form-title')
|
||||
formdef.fields.append(fields.FileField(id='4', label='file field', type='file', in_listing=True))
|
||||
formdef.store()
|
||||
|
||||
upload = PicklableUpload('test.jpeg', 'image/jpeg')
|
||||
jpg = open(os.path.join(os.path.dirname(__file__), 'image-with-gps-data.jpeg')).read()
|
||||
upload.receive([jpg])
|
||||
for formdata in formdef.data_class().select(lambda x: x.status == 'wf-new'):
|
||||
formdata.data['4'] = upload
|
||||
formdata.store()
|
||||
app = login(get_app(pub))
|
||||
resp = app.get('/backoffice/management/form-title/')
|
||||
assert 'download?f=4&thumbnail=1' not in resp.body
|
||||
|
||||
def test_backoffice_filter(pub):
|
||||
create_superuser(pub)
|
||||
create_environment(pub)
|
||||
|
|
|
@ -935,7 +935,7 @@ class FileField(WidgetField):
|
|||
t = TemplateIO(html=True)
|
||||
t += htmltext('<div class="file-field">')
|
||||
t += htmltext('<a download="%s" href="[download]?f=%s">') % (value.base_filename, self.id)
|
||||
if can_thumbnail(value.content_type):
|
||||
if include_image_thumbnail and can_thumbnail(value.content_type):
|
||||
t += htmltext('<img alt="" src="[download]?f=%s&thumbnail=1"/>') % self.id
|
||||
t += htmltext('<span>%s</span>') % value
|
||||
t += htmltext('</a></div>')
|
||||
|
|
Loading…
Reference in New Issue