Skip to content

Commit

Permalink
Fixes #3332 (#3333)
Browse files Browse the repository at this point in the history
  • Loading branch information
capooti authored and francbartoli committed Oct 4, 2017
1 parent b82e0cb commit d4140ce
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions geonode/contrib/datastore_shards/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,11 @@ def update_shard_layers_count(instance, sender, **kwargs):
Update layers_count for Database model.
"""
store_name = instance.store
shardatabase = Database.objects.get(name=store_name)
shardatabase.layers_count = Layer.objects.filter(store=store_name).count()
shardatabase.save()
# if layer is part of a shards we need to increment layers_count
if Database.objects.filter(name=store_name).exists():
shardatabase = Database.objects.get(name=store_name)
shardatabase.layers_count = Layer.objects.filter(store=store_name).count()
shardatabase.save()


signals.post_delete.connect(update_shard_layers_count, sender=Layer)
Expand Down

0 comments on commit d4140ce

Please sign in to comment.