backoffice: remove thumbnail references for file fields in tables (#31134)

This commit is contained in:
Frédéric Péters 2019-03-06 15:25:40 +01:00
parent 3df85143c6
commit 2b14b99f74
2 changed files with 18 additions and 1 deletions

View File

@ -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)

View File

@ -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>')