Skip to content

Commit

Permalink
- Fix layer replase
Browse files Browse the repository at this point in the history
  • Loading branch information
afabiani committed Apr 26, 2018
1 parent c47b75a commit 401ad5b
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions geonode/layers/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -569,7 +569,7 @@ def file_upload(filename,
# and the layer was not just created
# process the layer again after that by
# doing a layer.save()
if not created and overwrite:
if overwrite:
# update with new information
defaults['upload_session'] = upload_session
defaults['title'] = defaults.get('title', None) or layer.title
Expand All @@ -586,11 +586,7 @@ def file_upload(filename,
defaults['category'] = defaults.get('category', None) or layer.category

try:
if created:
db_layer = Layer.objects.filter(id=layer.id)
else:
db_layer = Layer.objects.filter(alternate=title)
db_layer.update(**defaults)
Layer.objects.filter(id=layer.id).update(**defaults)
layer.refresh_from_db()
except Layer.DoesNotExist:
import traceback
Expand All @@ -604,8 +600,9 @@ def file_upload(filename,

# Blank out the store if overwrite is true.
# geoserver_post_save_signal should upload the new file if needed
layer.store = ''
layer.save()
layer.store = '' if overwrite else layer.store
if created:
layer.save()

if upload_session:
upload_session.resource = layer
Expand Down

0 comments on commit 401ad5b

Please sign in to comment.