diff --git a/geonode/base/migrations/0072_remove_resourcebase_detail_url.py b/geonode/base/migrations/0072_remove_resourcebase_detail_url.py new file mode 100644 index 00000000000..95ecc954542 --- /dev/null +++ b/geonode/base/migrations/0072_remove_resourcebase_detail_url.py @@ -0,0 +1,17 @@ +# Generated by Django 3.2.4 on 2021-07-22 10:44 + +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('base', '0071_remove_resourcebase_ows_url'), + ] + + operations = [ + migrations.RemoveField( + model_name='resourcebase', + name='detail_url', + ), + ] diff --git a/geonode/base/models.py b/geonode/base/models.py index aa989912159..2a34651f6ec 100644 --- a/geonode/base/models.py +++ b/geonode/base/models.py @@ -938,7 +938,6 @@ class ResourceBase(PolymorphicModel, PermissionLevelMixin, ItemBase): # fields necessary for the apis thumbnail_url = models.TextField(_("Thumbnail url"), null=True, blank=True) - detail_url = models.CharField(max_length=255, null=True, blank=True) rating = models.IntegerField(default=0, null=True, blank=True) created = models.DateTimeField(auto_now_add=True, null=True, blank=True) last_updated = models.DateTimeField(auto_now=True, null=True, blank=True) @@ -1062,6 +1061,10 @@ def raw_supplemental_information(self): def raw_data_quality_statement(self): return self._remove_html_tags(self.data_quality_statement) + @property + def detail_url(self): + return self.get_absolute_url() + def save(self, notify=False, *args, **kwargs): """ Send a notification when a resource is created or updated @@ -1398,6 +1401,9 @@ def keyword_csv(self): except Exception: return '' + def get_absolute_url(self): + return '' + def set_bbox_polygon(self, bbox, srid): """ Set `bbox_polygon` from bbox values. diff --git a/geonode/documents/models.py b/geonode/documents/models.py index 97d402593e3..c4ec20c9b95 100644 --- a/geonode/documents/models.py +++ b/geonode/documents/models.py @@ -28,6 +28,7 @@ from django.contrib.contenttypes.models import ContentType from django.contrib.contenttypes.fields import GenericForeignKey +from geonode.client.hooks import hookset from geonode.maps.models import Map from geonode.layers.models import Dataset from geonode.base.models import ResourceBase @@ -56,7 +57,7 @@ def __str__(self): return str(self.title) def get_absolute_url(self): - return reverse('document_detail', args=(self.id,)) + return hookset.document_detail_url(self) @property def name(self): diff --git a/geonode/geoapps/migrations/0003_update_detail_url.py b/geonode/geoapps/migrations/0003_update_detail_url.py index ddf63f61ad7..ee2d071855b 100644 --- a/geonode/geoapps/migrations/0003_update_detail_url.py +++ b/geonode/geoapps/migrations/0003_update_detail_url.py @@ -1,13 +1,9 @@ from django.db import migrations -from django.db.models import Value -from django.db.models.functions import Concat from django.db.migrations.operations import RunPython -from geonode.geoapps.models import GeoApp - def update_geoapps_detail_url(apps, schema_editor): - GeoApp.objects.update(detail_url=Concat(Value('/apps/'), 'id')) + pass class Migration(migrations.Migration): diff --git a/geonode/geoapps/models.py b/geonode/geoapps/models.py index a1ffc3cc630..89570c4f1a4 100644 --- a/geonode/geoapps/models.py +++ b/geonode/geoapps/models.py @@ -25,6 +25,7 @@ from guardian.shortcuts import get_anonymous_user from geonode.base.models import ResourceBase +from geonode.client.hooks import hookset logger = logging.getLogger("geonode.geoapps.models") @@ -115,7 +116,7 @@ def keywords_list(self): return [] def get_absolute_url(self): - return reverse('geoapp_detail', None, [str(self.id)]) + return hookset.geoapp_detail_url(self) @property def embed_url(self): diff --git a/geonode/layers/models.py b/geonode/layers/models.py index 94f4303fa72..58c3e3bc1bb 100644 --- a/geonode/layers/models.py +++ b/geonode/layers/models.py @@ -27,6 +27,7 @@ from tinymce.models import HTMLField +from geonode.client.hooks import hookset from geonode.utils import check_shp_columnnames from geonode.security.models import PermissionLevelMixin from geonode.base.models import ( @@ -267,10 +268,7 @@ def get_base_file(self): return base_files.get(), list_col def get_absolute_url(self): - return reverse( - 'dataset_detail', - args=(f"{self.store}:{self.alternate}",) - ) + return hookset.dataset_detail_url(self) @property def embed_url(self): diff --git a/geonode/maps/models.py b/geonode/maps/models.py index 8c0d99cb5c7..9ce98cc6699 100644 --- a/geonode/maps/models.py +++ b/geonode/maps/models.py @@ -243,7 +243,7 @@ def keyword_list(self): return [] def get_absolute_url(self): - return reverse('map_detail', None, [str(self.id)]) + return hookset.map_detail_url(self) @property def embed_url(self): diff --git a/geonode/resource/utils.py b/geonode/resource/utils.py index 076aad9d7ab..1ee62c136a4 100644 --- a/geonode/resource/utils.py +++ b/geonode/resource/utils.py @@ -402,7 +402,6 @@ def metadata_post_save(instance, *args, **kwargs): instance.license = license[0] instance.thumbnail_url = instance.get_thumbnail_url() - instance.detail_url = instance.get_absolute_url() instance.csw_insert_date = datetime.datetime.now(timezone.get_current_timezone()) instance.set_missing_info() @@ -412,7 +411,6 @@ def metadata_post_save(instance, *args, **kwargs): alternate=instance.alternate, bbox_polygon=instance.bbox_polygon, thumbnail_url=instance.get_thumbnail_url(), - detail_url=instance.get_absolute_url(), csw_insert_date=datetime.datetime.now(timezone.get_current_timezone()) ) diff --git a/geonode/thumbs/tests/fixtures/resource_base.json b/geonode/thumbs/tests/fixtures/resource_base.json index 14205f22407..3d8abff6910 100644 --- a/geonode/thumbs/tests/fixtures/resource_base.json +++ b/geonode/thumbs/tests/fixtures/resource_base.json @@ -45,7 +45,6 @@ "is_published":true, "is_approved":true, "thumbnail_url":"http://localhost:8000/uploaded/thumbs/layer-2062a8d0-8000-11eb-bb7a-bfe60c5757ad-thumb.png?v=a20a765c", - "detail_url":"/datasets/geonode_data:geonode:theaters_nyc", "rating":0, "created":"2021-03-08T11:19:19.705Z", "last_updated":"2021-03-08T11:20:19.632Z", @@ -111,7 +110,6 @@ "is_published":true, "is_approved":true, "thumbnail_url":"http://localhost:8000/uploaded/thumbs/map-5d9349f8-8000-11eb-bb7a-bfe60c5757ad-thumb.png", - "detail_url":"/maps/2", "rating":0, "created":"2021-03-08T11:21:01.938Z", "last_updated":"2021-03-08T11:21:02.430Z", @@ -177,7 +175,6 @@ "is_published":true, "is_approved":true, "thumbnail_url":null, - "detail_url":null, "rating":0, "created":"2021-03-08T12:13:13.630Z", "last_updated":"2021-03-08T12:13:13.630Z", @@ -243,7 +240,6 @@ "is_published":true, "is_approved":true, "thumbnail_url":"http://localhost:8000/uploaded/thumbs/layer-ff18956a-8007-11eb-bb7a-bfe60c5757ad-thumb.png?v=0116247d", - "detail_url":"/datasets/geonode_data:geonode:Meteorite_Landings_from_NASA_Open_Data_Portal1", "rating":0, "created":"2021-03-08T12:15:39.793Z", "last_updated":"2021-03-08T12:15:49.726Z", @@ -309,7 +305,6 @@ "is_published":true, "is_approved":true, "thumbnail_url":"/static/geonode/img/missing_thumb.png", - "detail_url":"/datasets/httpwww502regionetoscanaitwmsrastercomrtwmsrtmapwmsmapwmsgeologiamap_resolution91:rt_geologia.dbg_risorse_minerarie", "rating":0, "created":"2021-03-08T12:20:29.973Z", "last_updated":"2021-03-08T12:20:29.973Z", @@ -375,7 +370,6 @@ "is_published":true, "is_approved":true, "thumbnail_url":"/static/geonode/img/missing_thumb.png", - "detail_url":"/maps/9", "rating":0, "created":"2021-03-08T12:24:40.617Z", "last_updated":"2021-03-08T12:24:41.447Z",