workflows: allow django templates to get image for geocoding (#68209)

This commit is contained in:
Frédéric Péters 2022-08-17 10:24:09 +02:00
parent 0ab0c2ea11
commit ecb013bdba
2 changed files with 11 additions and 7 deletions

View File

@ -3472,10 +3472,12 @@ def test_geolocate_image(pub):
item = GeolocateWorkflowStatusItem()
item.method = 'photo_variable'
item.photo_variable = '=form_var_file_raw'
item.perform(formdata)
assert int(formdata.geolocations['base']['lat']) == -1
assert int(formdata.geolocations['base']['lon']) == 6
for expression in ('=form_var_file_raw', '{{ form_var_file }}', '{{ form_var_file_raw }}'):
formdata.geolocations = None
item.photo_variable = expression
item.perform(formdata)
assert int(formdata.geolocations['base']['lat']) == -1
assert int(formdata.geolocations['base']['lon']) == 6
# invalid expression
formdata.geolocations = None

View File

@ -195,9 +195,11 @@ class GeolocateWorkflowStatusItem(WorkflowStatusItem):
if Image is None:
return
value = self.compute(self.photo_variable)
if not value:
return
with get_publisher().complex_data():
value = self.compute(self.photo_variable, allow_complex=True)
if not value:
return
value = get_publisher().get_cached_complex_data(value)
if not hasattr(value, 'get_file_pointer'):
return