Skip to content

Commit

Permalink
Fixes #11578: align geoapp metadata update to other resources
Browse files Browse the repository at this point in the history
  • Loading branch information
mattiagiupponi committed Oct 19, 2023
1 parent 47a9aa6 commit e8a64bc
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 12 deletions.
31 changes: 19 additions & 12 deletions geonode/geoapps/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -327,21 +327,15 @@ def geoapp_metadata(
geoapp_form.cleaned_data.pop("linked_resources")

geoapp_obj = geoapp_form.instance
geoapp_obj.keywords.clear()
geoapp_obj.keywords.add(*new_keywords)
geoapp_obj.regions.clear()
geoapp_obj.regions.add(*new_regions)
geoapp_obj.category = new_category

_vals = dict(**geoapp_form.cleaned_data, **additional_vals)
_vals.update({"resource_type": resource_type, "sourcetype": SOURCE_TYPE_LOCAL})

resource_manager.update(
geoapp_obj.uuid,
instance=geoapp_obj,
keywords=new_keywords,
regions=new_regions,
vals=_vals,
notify=True,
extra_metadata=json.loads(extra_metadata),
)
resource_manager.set_thumbnail(geoapp_obj.uuid, instance=geoapp_obj, overwrite=False)

register_event(request, EventType.EVENT_CHANGE_METADATA, geoapp_obj)
if not ajax:
return HttpResponseRedirect(hookset.geoapp_detail_url(geoapp_obj))
Expand Down Expand Up @@ -373,7 +367,20 @@ def geoapp_metadata(
if any([x in geoapp_form.changed_data for x in ["is_approved", "is_published"]]):
vals["is_approved"] = geoapp_form.cleaned_data.get("is_approved", geoapp_obj.is_approved)
vals["is_published"] = geoapp_form.cleaned_data.get("is_published", geoapp_obj.is_published)
resource_manager.update(geoapp_obj.uuid, instance=geoapp_obj, notify=True, vals=vals)
else:
vals.pop("is_approved", None)
vals.pop("is_published", None)

resource_manager.update(
geoapp_obj.uuid,
instance=geoapp_obj,
notify=True,
vals=vals,
extra_metadata=json.loads(extra_metadata),
)

resource_manager.set_thumbnail(geoapp_obj.uuid, instance=geoapp_obj, overwrite=False)

return HttpResponse(json.dumps({"message": message}))
elif request.method == "POST" and (
not geoapp_form.is_valid() or not category_form.is_valid() or not tkeywords_form.is_valid()
Expand Down
3 changes: 3 additions & 0 deletions geonode/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -2361,3 +2361,6 @@ def get_geonode_catalogue_service():
DEFAULT_DATASET_DOWNLOAD_HANDLER = "geonode.layers.download_handler.DatasetDownloadHandler"

DATASET_DOWNLOAD_HANDLERS = ast.literal_eval(os.getenv("DATASET_DOWNLOAD_HANDLERS", "[]"))

DEFAULT_ANONYMOUS_VIEW_PERMISSION = False
DEFAULT_ANONYMOUS_DOWNLOAD_PERMISSION = False

0 comments on commit e8a64bc

Please sign in to comment.