Skip to content

Commit

Permalink
[Fixes #12594] Error when saing a new map
Browse files Browse the repository at this point in the history
  • Loading branch information
mattiagiupponi committed Sep 24, 2024
1 parent 1892385 commit c1e69b2
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
6 changes: 3 additions & 3 deletions geonode/base/api/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -737,8 +737,8 @@ def to_internal_value(self, data):

def update(self, instance, validated_data):
user = self.context["request"].user
for field in user.APPROVAL_STATUS_FIELDS:
if not user.can_change_resource_field(instance, field) and field in user.APPROVAL_STATUS_FIELDS:
for field in instance.ROLE_BASED_MANAGED_FIELDS:
if not user.can_change_resource_field(instance, field) and field in validated_data:
validated_data.pop(field)

Check warning on line 742 in geonode/base/api/serializers.py

View check run for this annotation

Codecov / codecov/patch

geonode/base/api/serializers.py#L742

Added line #L742 was not covered by tests
return super().update(instance, validated_data)

Expand All @@ -760,7 +760,7 @@ def save(self, **kwargs):
instance.set_bbox_polygon(coords, srid)

user = self.context["request"].user
for field in user.APPROVAL_STATUS_FIELDS:
for field in instance.ROLE_BASED_MANAGED_FIELDS:
if not user.can_change_resource_field(instance, field):
logger.debug("User can perform the action, the default value is set")
setattr(user, field, getattr(ResourceBase, field).field.default)
Expand Down
3 changes: 3 additions & 0 deletions geonode/base/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -632,6 +632,9 @@ class ResourceBase(PolymorphicModel, PermissionLevelMixin, ItemBase):
Base Resource Object loosely based on ISO 19115:2003
"""

# fixing up the publishing option based on user permissions
ROLE_BASED_MANAGED_FIELDS = ["is_approved", "is_published", "featured"]

BASE_PERMISSIONS = {
"read": ["view_resourcebase"],
"write": ["change_resourcebase_metadata"],
Expand Down
3 changes: 0 additions & 3 deletions geonode/people/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,9 +151,6 @@ def class_name(value):
objects = ProfileUserManager()
USERNAME_FIELD = "username"

# fixing up the publishing option based on user permissions
APPROVAL_STATUS_FIELDS = ["is_approved", "is_published", "featured"]

def group_list_public(self):
return GroupProfile.objects.exclude(access="private").filter(groupmember__user=self)

Expand Down

0 comments on commit c1e69b2

Please sign in to comment.