From 0de263c6b451d4bc198c384a2922dde6d920ccda Mon Sep 17 00:00:00 2001 From: Irwan Fathurrahman Date: Tue, 27 Jul 2021 17:17:54 +0700 Subject: [PATCH] [Fixes #7761] Harvested resource permissions assignment must follow the same logic as uploaded resources (#7760) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Bump urllib3 from 1.26.2 to 1.26.3 (#6908) Bumps [urllib3](https://github.com/urllib3/urllib3) from 1.26.2 to 1.26.3. - [Release notes](https://github.com/urllib3/urllib3/releases) - [Changelog](https://github.com/urllib3/urllib3/blob/1.26.3/CHANGES.rst) - [Commits](https://github.com/urllib3/urllib3/compare/1.26.2...1.26.3) Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Toni * [Fixes #6880] Circle CI upload tests fail irregulary (#6881) * [Fixes #6880] Circle CI upload tests fail irregulary * CircleCI test fix: sometimes expires due to upload timeout in the test environment * - Avoid infinite loop on upload testing * Revert "CircleCI test fix: sometimes expires due to upload timeout in the test environment" This reverts commit 66139fdbf0b7510a9829a3e01254f41782fb7e1d. Co-authored-by: Alessio Fabiani Co-authored-by: afabiani * [Fixes #6914] Remove "add to basket" tool for documents and maps (#6915) * Added malnajdi as contributor * [Fixes #6910] meaningful filename for document download (#6911) * get meaningful document filenames on download * - Strip extension from document title before slugify it (e.g.: image.jpg instead of imagejpg.jpg) Co-authored-by: afabiani Co-authored-by: Alessio Fabiani * - CircleCI Upload Tests: trying to reduce more the risk of infinite loop on "wait_for_progress" * [Fixes #6916] gsimporter.api.NotFound caused by missing trailing slash at the end of GEOSERVER_LOCATION (#6913) * [Fixes #6916] gsimporter.api.NotFound caused by missing trailing slash at the end of GEOSERVER_LOCATION * [Fixes #6916] unit test for GEOSERVER_LOCATION * Bump django-cors-headers from 3.6.0 to 3.7.0 (#6901) Bumps [django-cors-headers](https://github.com/adamchainz/django-cors-headers) from 3.6.0 to 3.7.0. - [Release notes](https://github.com/adamchainz/django-cors-headers/releases) - [Changelog](https://github.com/adamchainz/django-cors-headers/blob/master/HISTORY.rst) - [Commits](https://github.com/adamchainz/django-cors-headers/compare/3.6.0...3.7.0) Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Bump amqp from 5.0.3 to 5.0.5 (#6905) Bumps [amqp](https://github.com/celery/py-amqp) from 5.0.3 to 5.0.5. - [Release notes](https://github.com/celery/py-amqp/releases) - [Changelog](https://github.com/celery/py-amqp/blob/master/Changelog) - [Commits](https://github.com/celery/py-amqp/compare/v5.0.3...v5.0.5) Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Bump pip from 21.0 to 21.0.1 (#6900) Bumps [pip](https://github.com/pypa/pip) from 21.0 to 21.0.1. - [Release notes](https://github.com/pypa/pip/releases) - [Changelog](https://github.com/pypa/pip/blob/master/NEWS.rst) - [Commits](https://github.com/pypa/pip/compare/21.0...21.0.1) Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Bump coverage from 5.3.1 to 5.4 (#6903) Bumps [coverage](https://github.com/nedbat/coveragepy) from 5.3.1 to 5.4. - [Release notes](https://github.com/nedbat/coveragepy/releases) - [Changelog](https://github.com/nedbat/coveragepy/blob/master/CHANGES.rst) - [Commits](https://github.com/nedbat/coveragepy/compare/coverage-5.3.1...coverage-5.4) Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Bump pytest from 6.2.1 to 6.2.2 (#6907) Bumps [pytest](https://github.com/pytest-dev/pytest) from 6.2.1 to 6.2.2. - [Release notes](https://github.com/pytest-dev/pytest/releases) - [Changelog](https://github.com/pytest-dev/pytest/blob/master/CHANGELOG.rst) - [Commits](https://github.com/pytest-dev/pytest/compare/6.2.1...6.2.2) Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Bump djangorestframework-gis from 0.16 to 0.17 (#6902) Bumps [djangorestframework-gis](https://github.com/openwisp/django-rest-framework-gis) from 0.16 to 0.17. - [Release notes](https://github.com/openwisp/django-rest-framework-gis/releases) - [Changelog](https://github.com/openwisp/django-rest-framework-gis/blob/master/CHANGES.rst) - [Commits](https://github.com/openwisp/django-rest-framework-gis/compare/v0.16.0...v0.17.0) Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * - Algin setup.cfg to requirements.txt * [Fixes #6922][REST API v2] Expose the curated thumbnail URL if it has… (#6923) * [Fixes #6922][REST API v2] Expose the curated thumbnail URL if it has been uploaded * - Add REST APIs test suite to CircleCI * [Fixes #6918] Removal of QGIS support (#6919) * [Cleanup and Refactor] Remove QGIS server backend dependencies * [Cleanup and Refactor] Remove QGIS server backend dependencies * - Fix LGTM issues * allow Basic authenticated requests in LOCKDOWN mode * fix to avoid circular import * flake8 check fix * added tests * [Fixes #6880] Circle CI upload tests fail irregulary (#6881) * [Fixes #6880] Circle CI upload tests fail irregulary * CircleCI test fix: sometimes expires due to upload timeout in the test environment * - Avoid infinite loop on upload testing * Revert "CircleCI test fix: sometimes expires due to upload timeout in the test environment" This reverts commit 66139fdbf0b7510a9829a3e01254f41782fb7e1d. Co-authored-by: Alessio Fabiani Co-authored-by: afabiani * [Fixes #6914] Remove "add to basket" tool for documents and maps (#6915) * Added malnajdi as contributor * Bump pip from 21.0 to 21.0.1 (#6900) Bumps [pip](https://github.com/pypa/pip) from 21.0 to 21.0.1. - [Release notes](https://github.com/pypa/pip/releases) - [Changelog](https://github.com/pypa/pip/blob/master/NEWS.rst) - [Commits](https://github.com/pypa/pip/compare/21.0...21.0.1) Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * - Algin setup.cfg to requirements.txt * [Fixes #6922][REST API v2] Expose the curated thumbnail URL if it has… (#6923) * [Fixes #6922][REST API v2] Expose the curated thumbnail URL if it has been uploaded * - Add REST APIs test suite to CircleCI * [Fixes #6918] Removal of QGIS support (#6919) * [Cleanup and Refactor] Remove QGIS server backend dependencies * [Cleanup and Refactor] Remove QGIS server backend dependencies * - Fix LGTM issues * allow Basic authenticated requests in LOCKDOWN mode * fix to avoid circular import * - Align to upstream master branch * Remove get_default_access_permissions from harvester Co-authored-by: Giovanni Allegri Co-authored-by: allyoucanmap Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Toni Co-authored-by: Alessio Fabiani Co-authored-by: afabiani Co-authored-by: Florian Hoedt Co-authored-by: Mohammed Y. Alnajdi Co-authored-by: biegan Co-authored-by: Ricardo Garcia Silva --- geonode/harvesting/api/serializers.py | 1 - geonode/harvesting/harvesters/base.py | 7 +------ ...alter_harvester_default_access_permissions.py | 2 +- ...emove_harvester_default_access_permissions.py | 16 ++++++++++++++++ geonode/harvesting/models.py | 10 ---------- 5 files changed, 18 insertions(+), 18 deletions(-) create mode 100644 geonode/harvesting/migrations/0027_remove_harvester_default_access_permissions.py diff --git a/geonode/harvesting/api/serializers.py b/geonode/harvesting/api/serializers.py index 3c206e02cb6..7d918db190c 100644 --- a/geonode/harvesting/api/serializers.py +++ b/geonode/harvesting/api/serializers.py @@ -105,7 +105,6 @@ class Meta: "scheduling_enabled", "update_frequency", "default_owner", - "default_access_permissions", "harvester_type", "harvester_type_specific_configuration", "update_frequency", diff --git a/geonode/harvesting/harvesters/base.py b/geonode/harvesting/harvesters/base.py index 51a1ff1f4fe..dd950b6e35a 100644 --- a/geonode/harvesting/harvesters/base.py +++ b/geonode/harvesting/harvesters/base.py @@ -164,7 +164,6 @@ def update_geonode_resource( harvesting_session_id: int, ): """Create or update a local GeoNode resource with the input harvested information.""" - harvester = models.Harvester.objects.get(pk=self.harvester_id) defaults = self.get_geonode_resource_defaults( harvested_info, harvestable_resource) geonode_resource = harvestable_resource.geonode_resource @@ -187,6 +186,7 @@ def update_geonode_resource( keywords = list( harvested_info.resource_descriptor.identification.other_keywords ) + geonode_resource.keyword_list() + harvester = models.Harvester.objects.get(pk=self.harvester_id) keywords.append( harvester.name.lower().replace( 'harvester ', '').replace( @@ -196,11 +196,6 @@ def update_geonode_resource( regions = harvested_info.resource_descriptor.identification.place_keywords resource_manager.update( str(harvested_info.resource_descriptor.uuid), regions=regions, keywords=list(set(keywords))) - - resource_manager.set_permissions( - str(harvested_info.resource_descriptor.uuid), - instance=geonode_resource, - permissions=harvester.default_access_permissions) harvestable_resource.geonode_resource = geonode_resource harvestable_resource.save() self.finalize_resource_update( diff --git a/geonode/harvesting/migrations/0022_alter_harvester_default_access_permissions.py b/geonode/harvesting/migrations/0022_alter_harvester_default_access_permissions.py index 10b13e40dc6..235ccb75be5 100644 --- a/geonode/harvesting/migrations/0022_alter_harvester_default_access_permissions.py +++ b/geonode/harvesting/migrations/0022_alter_harvester_default_access_permissions.py @@ -14,6 +14,6 @@ class Migration(migrations.Migration): migrations.AlterField( model_name='harvester', name='default_access_permissions', - field=models.JSONField(default=geonode.harvesting.models.get_default_access_permissions, help_text='Default access permissions of harvested resources'), + field=models.JSONField(help_text='Default access permissions of harvested resources'), ), ] diff --git a/geonode/harvesting/migrations/0027_remove_harvester_default_access_permissions.py b/geonode/harvesting/migrations/0027_remove_harvester_default_access_permissions.py new file mode 100644 index 00000000000..3ca9ea8dbf2 --- /dev/null +++ b/geonode/harvesting/migrations/0027_remove_harvester_default_access_permissions.py @@ -0,0 +1,16 @@ +# Generated by Django 3.2.4 on 2021-07-08 13:14 + +from django.db import migrations + + +class Migration(migrations.Migration): + dependencies = [ + ('harvesting', '0026_harvestableresource_last_harvesting_succeeded'), + ] + + operations = [ + migrations.RemoveField( + model_name='harvester', + name='default_access_permissions', + ), + ] diff --git a/geonode/harvesting/models.py b/geonode/harvesting/models.py index bba30cf7532..fa732904dfd 100644 --- a/geonode/harvesting/models.py +++ b/geonode/harvesting/models.py @@ -38,12 +38,6 @@ logger = logging.getLogger(__name__) -def get_default_access_permissions(): - return { - "AnonymousUser": ["view"] - } - - class Harvester(models.Model): STATUS_READY = "ready" STATUS_UPDATING_HARVESTABLE_RESOURCES = "updating-harvestable-resources" @@ -105,10 +99,6 @@ class Harvester(models.Model): on_delete=models.CASCADE, help_text=_("Default owner of harvested resources") ) - default_access_permissions = models.JSONField( - default=get_default_access_permissions, - help_text=_("Default access permissions of harvested resources") - ) harvest_new_resources_by_default = models.BooleanField( help_text=_( "Should new resources be harvested automatically without "