Skip to content

Commit

Permalink
Merge branch 'v.3.8.x' into client_update_dependencies_v3.8.5
Browse files Browse the repository at this point in the history
  • Loading branch information
wlorenzetti authored Dec 23, 2024
2 parents 14c28d5 + 5c0de56 commit d857e90
Showing 1 changed file with 20 additions and 5 deletions.
25 changes: 20 additions & 5 deletions g3w-admin/core/utils/vector.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,15 @@ def get_domain(self):
else:
return '{}://{}'.format(schema, self.request.get_host())

def _new_path(self, file_name):
""" Build new path to save media file """

return reverse('user-media', kwargs={
'project_type': self.type,
'layer_id': self.layer.pk,
'file_name': file_name
})

def new_value(self, change=False):
""" Build and save media value from client """

Expand Down Expand Up @@ -162,11 +171,17 @@ def new_value(self, change=False):
# build new value

self.feature_properties[field] = '{}{}'.format(self.get_domain(),
reverse('user-media', kwargs={
'project_type': self.type,
'layer_id': self.layer.pk,
'file_name': file_name
}))
self._new_path(file_name))
else:
if is_media_view:

value = current_field_value
# Try to fix old record saved with temp_uploads path
if os.path.exists(path_file_to_save):
value = self._new_path(file_name)

# Restore to current_feature value
self.feature_properties[field] = value

if delete_old:
to_delete = '{}/{}'.format(path_to_save, current_file_name)
Expand Down

0 comments on commit d857e90

Please sign in to comment.