Skip to content

Commit

Permalink
[3.3.x][Fixes #8429]GeoApps have empty uuid (#8473) (#8482)
Browse files Browse the repository at this point in the history
* [Fixes #8429]GeoApps have empty uuid

* save uuid on resource

(cherry picked from commit 7028379)

Co-authored-by: NAGGINDA MARTHA <[email protected]>
  • Loading branch information
Alessio Fabiani and marthamareal authored Dec 10, 2021
1 parent a2f466a commit c449510
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
6 changes: 5 additions & 1 deletion geonode/base/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -2004,11 +2004,15 @@ def resourcebase_post_save(instance, *args, **kwargs):
if license and len(license) > 0:
instance.license = license[0]

if instance.uuid is None or instance.uuid == '':
instance.uuid = str(uuid.uuid1())

ResourceBase.objects.filter(id=instance.id).update(
thumbnail_url=instance.get_thumbnail_url(),
detail_url=instance.get_absolute_url(),
csw_insert_date=now(),
license=instance.license)
license=instance.license,
uuid=instance.uuid)
instance.refresh_from_db()
except Exception:
tb = traceback.format_exc()
Expand Down
3 changes: 3 additions & 0 deletions geonode/geoapps/api/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,9 @@ def test_geoapps_crud(self):
}
response = self.client.post(url, data=data, format='json')
self.assertEqual(response.status_code, 201) # 201 - Created
# Check uuid is populate
app = GeoApp.objects.last()
self.assertTrue(app.uuid)

response = self.client.get(url, format='json')
self.assertEqual(response.status_code, 200)
Expand Down
2 changes: 2 additions & 0 deletions geonode/geoapps/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,5 @@ def test_update_geoapp_metadata(self):
self.assertEqual(response.status_code, 200)
self.assertEqual(gep_app.thumbnail_url, GeoApp.objects.get(id=gep_app.id).thumbnail_url)
self.assertEqual(GeoApp.objects.get(id=gep_app.id).title, 'New title')
# Check uuid is populate
self.assertTrue(GeoApp.objects.get(id=gep_app.id).uuid)

0 comments on commit c449510

Please sign in to comment.