Skip to content

Commit

Permalink
- use correct resolved object when saving metadata
Browse files Browse the repository at this point in the history
  • Loading branch information
afabiani committed Jul 9, 2019
1 parent 0f5709f commit 4d07ff4
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 32 deletions.
4 changes: 4 additions & 0 deletions geonode/base/models.py
Expand Up @@ -1497,6 +1497,10 @@ def resourcebase_post_save(instance, *args, **kwargs):
if tb:
logger.debug(tb)

# refresh catalogue metadata records
from geonode.catalogue.models import catalogue_post_save
catalogue_post_save(instance=instance, sender=instance.__class__)


def rating_post_save(instance, *args, **kwargs):
"""
Expand Down
20 changes: 9 additions & 11 deletions geonode/documents/views.py
Expand Up @@ -420,21 +420,19 @@ def document_metadata(
if author_form.has_changed and author_form.is_valid():
new_author = author_form.save()

the_document = document_form.instance
document = document_form.instance
if new_poc is not None and new_author is not None:
the_document.poc = new_poc
the_document.metadata_author = new_author
document.poc = new_poc
document.metadata_author = new_author
if new_keywords:
the_document.keywords.clear()
the_document.keywords.add(*new_keywords)
document.keywords.clear()
document.keywords.add(*new_keywords)
if new_regions:
the_document.regions.clear()
the_document.regions.add(*new_regions)
the_document.save()
document.regions.clear()
document.regions.add(*new_regions)
document.category = new_category
document.save()
document_form.save_many2many()
Document.objects.filter(
id=the_document.id).update(
category=new_category)

if not ajax:
return HttpResponseRedirect(
Expand Down
15 changes: 5 additions & 10 deletions geonode/layers/views.py
Expand Up @@ -1074,17 +1074,12 @@ def layer_metadata(
if new_regions is not None:
layer.regions.clear()
layer.regions.add(*new_regions)
layer.category = new_category
layer.save()

the_layer = layer_form.instance
the_layer.save()

up_sessions = UploadSession.objects.filter(layer=the_layer.id)
if up_sessions.count() > 0 and up_sessions[0].user != the_layer.owner:
up_sessions.update(user=the_layer.owner)

Layer.objects.filter(id=the_layer.id).update(
category=new_category
)
up_sessions = UploadSession.objects.filter(layer=layer)
if up_sessions.count() > 0 and up_sessions[0].user != layer.owner:
up_sessions.update(user=layer.owner)

if not ajax:
return HttpResponseRedirect(
Expand Down
21 changes: 10 additions & 11 deletions geonode/maps/views.py
Expand Up @@ -241,20 +241,19 @@ def map_metadata(
if author_form.has_changed and author_form.is_valid():
new_author = author_form.save()

the_map = map_form.instance
if new_poc is not None and new_author is not None:
the_map.poc = new_poc
the_map.metadata_author = new_author
the_map.title = new_title
the_map.abstract = new_abstract
map_obj.poc = new_poc
map_obj.metadata_author = new_author
map_obj.title = new_title
map_obj.abstract = new_abstract
if new_keywords:
the_map.keywords.clear()
the_map.keywords.add(*new_keywords)
map_obj.keywords.clear()
map_obj.keywords.add(*new_keywords)
if new_regions:
the_map.regions.clear()
the_map.regions.add(*new_regions)
the_map.category = new_category
the_map.save()
map_obj.regions.clear()
map_obj.regions.add(*new_regions)
map_obj.category = new_category
map_obj.save()

if not ajax:
return HttpResponseRedirect(
Expand Down

0 comments on commit 4d07ff4

Please sign in to comment.