Skip to content

Commit

Permalink
Uploadsession can be empty under certain circomstancies, ie layer cas…
Browse files Browse the repository at this point in the history
…cade delete when removing an user
  • Loading branch information
capooti committed Jul 13, 2015
1 parent c2c1a6f commit a663ede
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions geonode/layers/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -509,9 +509,12 @@ def post_delete_layer(instance, sender, **kwargs):
default_style__id=instance.default_style.id).count() == 0:
instance.default_style.delete()

if instance.upload_session:
for lf in instance.upload_session.layerfile_set.all():
lf.file.delete()
try:
if instance.upload_session:
for lf in instance.upload_session.layerfile_set.all():
lf.file.delete()
except UploadSession.DoesNotExist:
pass


signals.pre_save.connect(pre_save_layer, sender=Layer)
Expand Down

0 comments on commit a663ede

Please sign in to comment.