Skip to content

Commit

Permalink
fix Object of type Map is not JSON serializable
Browse files Browse the repository at this point in the history
  • Loading branch information
hisham waleed karam committed Feb 14, 2019
1 parent 33690e6 commit 2675ca3
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 6 deletions.
15 changes: 12 additions & 3 deletions geonode/geoserver/signals.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,11 @@ def geoserver_post_save(instance, sender, **kwargs):
producer.geoserver_upload_layer(payload)
logger.info("... Creating Thumbnail for Layer [%s]" % (instance.alternate))
try:
thumbnail_task.delay(instance, overwrite=True, check_bbox=True)
thumbnail_task.delay(
instance.id,
instance.__class__.__name__,
overwrite=True,
check_bbox=True)
except BaseException:
logger.warn("!WARNING! - Failure while Creating Thumbnail for Layer [%s]" % (instance.alternate))

Expand Down Expand Up @@ -515,7 +519,8 @@ def command_url(command):
if 'update_fields' in kwargs and kwargs['update_fields'] is not None and \
'thumbnail_url' in kwargs['update_fields']:
logger.info("... Creating Thumbnail for Layer [%s]" % (instance.alternate))
thumbnail_task.delay(instance, overwrite=True)
thumbnail_task.delay(
instance.id, instance.__class__.__name__, overwrite=True)

try:
Link.objects.filter(resource=instance.resourcebase_ptr, name='Legend').delete()
Expand Down Expand Up @@ -644,4 +649,8 @@ def geoserver_pre_save_maplayer(instance, sender, **kwargs):
def geoserver_post_save_map(instance, sender, **kwargs):
instance.set_missing_info()
logger.info("... Creating Thumbnail for Map [%s]" % (instance.title))
thumbnail_task.delay(instance, overwrite=False, check_bbox=True)
thumbnail_task.delay(
instance.id,
instance.__class__.__name__,
overwrite=False,
check_bbox=True)
19 changes: 17 additions & 2 deletions geonode/geoserver/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
#########################################################################
from celery.app import shared_task
from celery.utils.log import get_task_logger

from .helpers import gs_slurp

logger = get_task_logger(__name__)
Expand All @@ -34,6 +33,22 @@ def geoserver_update_layers(self, *args, **kwargs):


@shared_task(bind=True)
def thumbnail_task(self, instance, overwrite=False, check_bbox=False):
def thumbnail_task(self,
instance_id,
instance_type,
overwrite=False,
check_bbox=False):
if instance_type == 'Layer':
from geonode.layers.models import Layer
instance = Layer.objects.get(id=instance_id)
elif instance_type == 'Map':
from geonode.maps.models import Map
instance = Map.objects.get(id=instance_id)
elif instance_type == 'Document':
from geonode.documents.models import Document
instance = Document.objects.get(id=instance_id)
else:
from geonode.base.models import ResourceBase
instance = ResourceBase.objects.get(id=instance_id)
from .helpers import create_gs_thumbnail
create_gs_thumbnail(instance, overwrite, check_bbox)
6 changes: 5 additions & 1 deletion geonode/security/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,11 @@ def synch_guardian():
sync_geofence_with_guardian(layer, perms, group=group)

try:
thumbnail_task.delay(layer, overwrite=True, check_bbox=True)
thumbnail_task.delay(
layer.id,
layer.__class__.__name__,
overwrite=True,
check_bbox=True)
except BaseException:
logger.warn("!WARNING! - Failure while Creating Thumbnail \
for Layer [%s]" % (layer.alternate))
Expand Down

0 comments on commit 2675ca3

Please sign in to comment.