api: add file URL to geojson data for file fields (#72371) #532
|
@ -2723,6 +2723,7 @@ def test_api_geojson_formdata(pub, local_user):
|
|||
'<div class="file-field"><a download="test.txt" href="http://example.net/backoffice/management/test/28/download?f=1">'
|
||||
'<span>test.txt</span></a></div>'
|
||||
)
|
||||
assert field['file_url'] == 'http://example.net/backoffice/management/test/28/download?f=1'
|
||||
field_varnames = [f['varname'] for f in display_fields]
|
||||
assert 'foobar' not in field_varnames
|
||||
|
||||
|
|
|
@ -126,14 +126,17 @@ def geojson_formdatas(formdatas, geoloc_key='base', fields=None):
|
|||
if not html_value and not value:
|
||||
continue
|
||||
|
||||
display_fields.append(
|
||||
{
|
||||
'varname': field.varname,
|
||||
'label': field.label,
|
||||
'value': str(value),
|
||||
'html_value': str(htmlescape(html_value)),
|
||||
}
|
||||
)
|
||||
geojson_infos = {
|
||||
'varname': field.varname,
|
||||
'label': field.label,
|
||||
'value': str(value),
|
||||
'html_value': str(htmlescape(html_value)),
|
||||
}
|
||||
if field.key == 'file':
|
||||
raw_value = formdata.data.get(field.id)
|
||||
if raw_value.has_redirect_url():
|
||||
geojson_infos['file_url'] = field.get_download_url(file_value=raw_value)
|
||||
display_fields.append(geojson_infos)
|
||||
|
||||
feature = {
|
||||
'type': 'Feature',
|
||||
|
|
Loading…
Reference in New Issue