Skip to content

Commit

Permalink
[Fixes #11962] Activate resource publishing outside Advanced workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
mattiagiupponi committed Feb 15, 2024
1 parent 3a9e11d commit b4daafb
Show file tree
Hide file tree
Showing 27 changed files with 129 additions and 120 deletions.
2 changes: 1 addition & 1 deletion .env.sample
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ CREATE_LAYER=True
FAVORITE_ENABLED=True

# Advanced Workflow
RESOURCE_PUBLISHING=False
ADMIN_RESOURCE_PUBLISHING=False
ADMIN_MODERATE_UPLOADS=False

# LDAP
Expand Down
2 changes: 1 addition & 1 deletion .env_dev
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ CREATE_LAYER=True
FAVORITE_ENABLED=True

# Advanced Workflow
RESOURCE_PUBLISHING=False
ADMIN_RESOURCE_PUBLISHING=False
ADMIN_MODERATE_UPLOADS=False

# PostgreSQL
Expand Down
2 changes: 1 addition & 1 deletion .env_local
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ CREATE_LAYER=True
FAVORITE_ENABLED=True

# Advanced Workflow
RESOURCE_PUBLISHING=False
ADMIN_RESOURCE_PUBLISHING=False
ADMIN_MODERATE_UPLOADS=False

# PostgreSQL
Expand Down
2 changes: 1 addition & 1 deletion .env_test
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ CREATE_LAYER=True
FAVORITE_ENABLED=True

# Advanced Workflow
RESOURCE_PUBLISHING=False
ADMIN_RESOURCE_PUBLISHING=False
ADMIN_MODERATE_UPLOADS=False

# PostgreSQL
Expand Down
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -492,7 +492,7 @@
* Advanced Upload Workflow Improvements:
- Non admin user cannot change permission
- Disable edit permissions globally when read-only mode is active
- RESOURCE_PUBLISHING:
- ADMIN_RESOURCE_PUBLISHING:
1. "unpublished" won't be visible to Anonymous users
2. "unpublished" will be visible to registered users **IF** they have view permissions
3. "unpublished" will be always visible to the owner and Group Managers
Expand Down
12 changes: 6 additions & 6 deletions geonode/api/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,8 @@ def get_resources_counts(self, options):
resources = get_visible_resources(
resources,
options["user"],
admin_approval_required=settings.ADMIN_MODERATE_UPLOADS,
unpublished_not_visible=settings.RESOURCE_PUBLISHING,
admin_moderate_uplaods=settings.ADMIN_MODERATE_UPLOADS,
admin_resource_publishing=settings.ADMIN_RESOURCE_PUBLISHING,
private_groups_not_visibile=settings.GROUP_PRIVATE_RESOURCES,
)

Expand Down Expand Up @@ -285,8 +285,8 @@ def dehydrate_datasets_count(self, bundle):
filter_set = get_visible_resources(
filter_set,
request.user if request else None,
admin_approval_required=settings.ADMIN_MODERATE_UPLOADS,
unpublished_not_visible=settings.RESOURCE_PUBLISHING,
admin_moderate_uplaods=settings.ADMIN_MODERATE_UPLOADS,
admin_resource_publishing=settings.ADMIN_RESOURCE_PUBLISHING,
private_groups_not_visibile=settings.GROUP_PRIVATE_RESOURCES,
)

Expand Down Expand Up @@ -711,8 +711,8 @@ def _get_resource_counts(request, resourcebase_filter_kwargs):
ResourceBase.objects.filter(**resourcebase_filter_kwargs),
request.user,
request=request,
admin_approval_required=settings.ADMIN_MODERATE_UPLOADS,
unpublished_not_visible=settings.RESOURCE_PUBLISHING,
admin_moderate_uplaods=settings.ADMIN_MODERATE_UPLOADS,
admin_resource_publishing=settings.ADMIN_RESOURCE_PUBLISHING,
private_groups_not_visibile=settings.GROUP_PRIVATE_RESOURCES,
)

Expand Down
4 changes: 2 additions & 2 deletions geonode/api/resourcebase_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,8 +215,8 @@ def apply_filters(self, request, applicable_filters):
filtered,
request.user if request else None,
metadata_only=metadata_only,
admin_approval_required=settings.ADMIN_MODERATE_UPLOADS,
unpublished_not_visible=settings.RESOURCE_PUBLISHING,
admin_moderate_uplaods=settings.ADMIN_MODERATE_UPLOADS,
admin_resource_publishing=settings.ADMIN_RESOURCE_PUBLISHING,
private_groups_not_visibile=settings.GROUP_PRIVATE_RESOURCES,
)

Expand Down
2 changes: 1 addition & 1 deletion geonode/api/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ def test_dataset_get_list_dataset_private_to_one_user(self):
layer.save()

# with resource publishing
with self.settings(RESOURCE_PUBLISHING=True):
with self.settings(ADMIN_RESOURCE_PUBLISHING=True):
resp = self.api_client.get(list_url)
self.assertGreaterEqual(len(self.deserialize(resp)["objects"]), 7)

Expand Down
4 changes: 2 additions & 2 deletions geonode/base/api/permissions.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,8 +204,8 @@ def filter_queryset(self, request, queryset, view):
queryset,
request.user,
metadata_only=metadata_only,
admin_approval_required=settings.ADMIN_MODERATE_UPLOADS,
unpublished_not_visible=settings.RESOURCE_PUBLISHING,
admin_moderate_uplaods=settings.ADMIN_MODERATE_UPLOADS,
admin_resource_publishing=settings.ADMIN_RESOURCE_PUBLISHING,
private_groups_not_visibile=settings.GROUP_PRIVATE_RESOURCES,
)

Expand Down
8 changes: 4 additions & 4 deletions geonode/base/api/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,8 +153,8 @@ def resources(self, request, pk=None):
resources = get_visible_resources(
qs,
user,
admin_approval_required=settings.ADMIN_MODERATE_UPLOADS,
unpublished_not_visible=settings.RESOURCE_PUBLISHING,
admin_moderate_uplaods=settings.ADMIN_MODERATE_UPLOADS,
admin_resource_publishing=settings.ADMIN_RESOURCE_PUBLISHING,
private_groups_not_visibile=settings.GROUP_PRIVATE_RESOURCES,
)

Expand Down Expand Up @@ -1529,8 +1529,8 @@ def base_linked_resources(instance, user, params):
visibile_resources = get_visible_resources(
ResourceBase.objects,
user=user,
admin_approval_required=settings.ADMIN_MODERATE_UPLOADS,
unpublished_not_visible=settings.RESOURCE_PUBLISHING,
admin_moderate_uplaods=settings.ADMIN_MODERATE_UPLOADS,
admin_resource_publishing=settings.ADMIN_RESOURCE_PUBLISHING,
private_groups_not_visibile=settings.GROUP_PRIVATE_RESOURCES,
).order_by("-pk")
visible_ids = [res.id for res in visibile_resources]
Expand Down
4 changes: 2 additions & 2 deletions geonode/base/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -300,8 +300,8 @@ def resource_keywords_tree(cls, user, parent=None, resource_type=None, resource_
resources = get_visible_resources(
resources,
user,
admin_approval_required=settings.ADMIN_MODERATE_UPLOADS,
unpublished_not_visible=settings.RESOURCE_PUBLISHING,
admin_moderate_uplaods=settings.ADMIN_MODERATE_UPLOADS,
admin_resource_publishing=settings.ADMIN_RESOURCE_PUBLISHING,
private_groups_not_visibile=settings.GROUP_PRIVATE_RESOURCES,
)

Expand Down
20 changes: 10 additions & 10 deletions geonode/base/templatetags/base_tags.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,8 @@ def facets(context):
geoapps = get_visible_resources(
apps.get_model(label, app.default_model).objects.all(),
request.user if request else None,
admin_approval_required=settings.ADMIN_MODERATE_UPLOADS,
unpublished_not_visible=settings.RESOURCE_PUBLISHING,
admin_moderate_uplaods=settings.ADMIN_MODERATE_UPLOADS,
admin_resource_publishing=settings.ADMIN_RESOURCE_PUBLISHING,
private_groups_not_visibile=settings.GROUP_PRIVATE_RESOURCES,
)

Expand Down Expand Up @@ -154,8 +154,8 @@ def facets(context):
documents = get_visible_resources(
documents,
request.user if request else None,
admin_approval_required=settings.ADMIN_MODERATE_UPLOADS,
unpublished_not_visible=settings.RESOURCE_PUBLISHING,
admin_moderate_uplaods=settings.ADMIN_MODERATE_UPLOADS,
admin_resource_publishing=settings.ADMIN_RESOURCE_PUBLISHING,
private_groups_not_visibile=settings.GROUP_PRIVATE_RESOURCES,
)

Expand Down Expand Up @@ -201,8 +201,8 @@ def facets(context):
layers = get_visible_resources(
layers,
request.user if request else None,
admin_approval_required=settings.ADMIN_MODERATE_UPLOADS,
unpublished_not_visible=settings.RESOURCE_PUBLISHING,
admin_moderate_uplaods=settings.ADMIN_MODERATE_UPLOADS,
admin_resource_publishing=settings.ADMIN_RESOURCE_PUBLISHING,
private_groups_not_visibile=settings.GROUP_PRIVATE_RESOURCES,
)

Expand Down Expand Up @@ -280,15 +280,15 @@ def facets(context):
maps = get_visible_resources(
maps,
request.user if request else None,
admin_approval_required=settings.ADMIN_MODERATE_UPLOADS,
unpublished_not_visible=settings.RESOURCE_PUBLISHING,
admin_moderate_uplaods=settings.ADMIN_MODERATE_UPLOADS,
admin_resource_publishing=settings.ADMIN_RESOURCE_PUBLISHING,
private_groups_not_visibile=settings.GROUP_PRIVATE_RESOURCES,
)
documents = get_visible_resources(
documents,
request.user if request else None,
admin_approval_required=settings.ADMIN_MODERATE_UPLOADS,
unpublished_not_visible=settings.RESOURCE_PUBLISHING,
admin_moderate_uplaods=settings.ADMIN_MODERATE_UPLOADS,
admin_resource_publishing=settings.ADMIN_RESOURCE_PUBLISHING,
private_groups_not_visibile=settings.GROUP_PRIVATE_RESOURCES,
)

Expand Down
8 changes: 4 additions & 4 deletions geonode/base/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -276,8 +276,8 @@ def get_queryset(self):
return get_visible_resources(
qs,
request.user if request else None,
admin_approval_required=settings.ADMIN_MODERATE_UPLOADS,
unpublished_not_visible=settings.RESOURCE_PUBLISHING,
admin_moderate_uplaods=settings.ADMIN_MODERATE_UPLOADS,
admin_resource_publishing=settings.ADMIN_RESOURCE_PUBLISHING,
private_groups_not_visibile=settings.GROUP_PRIVATE_RESOURCES,
)[:100]

Expand All @@ -295,8 +295,8 @@ def get_queryset(self):
return get_visible_resources(
qs,
self.request.user if self.request else None,
admin_approval_required=settings.ADMIN_MODERATE_UPLOADS,
unpublished_not_visible=settings.RESOURCE_PUBLISHING,
admin_moderate_uplaods=settings.ADMIN_MODERATE_UPLOADS,
admin_resource_publishing=settings.ADMIN_RESOURCE_PUBLISHING,
private_groups_not_visibile=settings.GROUP_PRIVATE_RESOURCES,
)

Expand Down
2 changes: 1 addition & 1 deletion geonode/context_processors.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def resource_urls(request):
TOPICCATEGORY_MANDATORY=getattr(settings, "TOPICCATEGORY_MANDATORY", False),
GROUP_MANDATORY_RESOURCES=getattr(settings, "GROUP_MANDATORY_RESOURCES", False),
GROUP_PRIVATE_RESOURCES=getattr(settings, "GROUP_PRIVATE_RESOURCES", False),
RESOURCE_PUBLISHING=getattr(settings, "RESOURCE_PUBLISHING", False),
ADMIN_RESOURCE_PUBLISHING=getattr(settings, "ADMIN_RESOURCE_PUBLISHING", False),
SKIP_PERMS_FILTER=getattr(settings, "SKIP_PERMS_FILTER", False),
CLIENT_RESULTS_LIMIT=getattr(settings, "CLIENT_RESULTS_LIMIT", 10),
API_LIMIT_PER_PAGE=getattr(settings, "API_LIMIT_PER_PAGE", 20),
Expand Down
4 changes: 2 additions & 2 deletions geonode/documents/api/permissions.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ def filter_queryset(self, request, queryset, view):
obj_with_perms = get_visible_resources(
resources,
user,
admin_approval_required=settings.ADMIN_MODERATE_UPLOADS,
unpublished_not_visible=settings.RESOURCE_PUBLISHING,
admin_moderate_uplaods=settings.ADMIN_MODERATE_UPLOADS,
admin_resource_publishing=settings.ADMIN_RESOURCE_PUBLISHING,
private_groups_not_visibile=settings.GROUP_PRIVATE_RESOURCES,
)

Expand Down
4 changes: 2 additions & 2 deletions geonode/geoapps/api/permissions.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ def filter_queryset(self, request, queryset, view):
_allowed_ids = get_visible_resources(
resources,
user,
admin_approval_required=settings.ADMIN_MODERATE_UPLOADS,
unpublished_not_visible=settings.RESOURCE_PUBLISHING,
admin_moderate_uplaods=settings.ADMIN_MODERATE_UPLOADS,
admin_resource_publishing=settings.ADMIN_RESOURCE_PUBLISHING,
private_groups_not_visibile=settings.GROUP_PRIVATE_RESOURCES,
).values_list("id", flat=True)

Expand Down
2 changes: 1 addition & 1 deletion geonode/geoserver/createlayer/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ def create_gn_dataset(workspace, datastore, name, title, owner_name):
to_update = {}
if settings.ADMIN_MODERATE_UPLOADS:
to_update["is_approved"] = to_update["was_approved"] = False
if settings.RESOURCE_PUBLISHING:
if settings.ADMIN_RESOURCE_PUBLISHING:
to_update["is_published"] = to_update["was_published"] = False

resource_manager.update(layer.uuid, instance=layer, vals=to_update)
Expand Down
2 changes: 1 addition & 1 deletion geonode/geoserver/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -2098,7 +2098,7 @@ def sync_instance_with_geoserver(instance_id, *args, **kwargs):
gs_resource.attribution_link = site_url + profile.get_absolute_url()

try:
if settings.RESOURCE_PUBLISHING:
if settings.ADMIN_RESOURCE_PUBLISHING:
if instance.is_published != gs_resource.advertised:
gs_resource.advertised = "true"

Expand Down
4 changes: 2 additions & 2 deletions geonode/geoserver/tests/integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ def test_unpublished(self):
layer.delete()

# with settings disabled
with self.settings(RESOURCE_PUBLISHING=True):
with self.settings(ADMIN_RESOURCE_PUBLISHING=True):
layer = Dataset.objects.first()
layer.is_approved = False
layer.is_published = False
Expand Down Expand Up @@ -284,7 +284,7 @@ def test_default_anonymous_permissions(self):
anonymous = get_user_model().objects.get(username="AnonymousUser")
norman = get_user_model().objects.get(username="norman")
with override_settings(
RESOURCE_PUBLISHING=False,
ADMIN_RESOURCE_PUBLISHING=False,
ADMIN_MODERATE_UPLOADS=False,
DEFAULT_ANONYMOUS_VIEW_PERMISSION=True,
DEFAULT_ANONYMOUS_DOWNLOAD_PERMISSION=False,
Expand Down
4 changes: 2 additions & 2 deletions geonode/layers/api/permissions.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ def filter_queryset(self, request, queryset, view):
obj_with_perms = get_visible_resources(
resources,
user,
admin_approval_required=settings.ADMIN_MODERATE_UPLOADS,
unpublished_not_visible=settings.RESOURCE_PUBLISHING,
admin_moderate_uplaods=settings.ADMIN_MODERATE_UPLOADS,
admin_resource_publishing=settings.ADMIN_RESOURCE_PUBLISHING,
private_groups_not_visibile=settings.GROUP_PRIVATE_RESOURCES,
)

Expand Down
4 changes: 2 additions & 2 deletions geonode/maps/api/permissions.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ def filter_queryset(self, request, queryset, view):
obj_with_perms = get_visible_resources(
resources,
user,
admin_approval_required=settings.ADMIN_MODERATE_UPLOADS,
unpublished_not_visible=settings.RESOURCE_PUBLISHING,
admin_moderate_uplaods=settings.ADMIN_MODERATE_UPLOADS,
admin_resource_publishing=settings.ADMIN_RESOURCE_PUBLISHING,
private_groups_not_visibile=settings.GROUP_PRIVATE_RESOURCES,
)

Expand Down

0 comments on commit b4daafb

Please sign in to comment.