Skip to content

Commit

Permalink
[Fixes GeoNode#12170] unable to set advanced contact roles in metadat…
Browse files Browse the repository at this point in the history
…a editor
  • Loading branch information
mwallschlaeger committed Apr 19, 2024
1 parent 728b705 commit 031c68a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
8 changes: 6 additions & 2 deletions geonode/base/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -1755,9 +1755,13 @@ def __create_role__(
ContactRole.objects.filter(role=role, resource=self).delete()
return __create_role__(self, role, user_profile)

elif isinstance(user_profile, list) and all(isinstance(x, get_user_model()) for x in user_profile):
elif isinstance(user_profile, list) and all(
get_user_model().objects.filter(username=x).exists() for x in user_profile
):
ContactRole.objects.filter(role=role, resource=self).delete()
return [__create_role__(self, role, profile) for profile in user_profile]
return [
__create_role__(self, role, user) for user in get_user_model().objects.filter(username__in=user_profile)
]

elif user_profile is None:
ContactRole.objects.filter(role=role, resource=self).delete()
Expand Down
5 changes: 2 additions & 3 deletions geonode/base/widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,8 @@ def value_from_datadict(self, data, files, name) -> List[str]:
returns list of selected elements
"""
if type(data) is dict and "name" in data:
return data["name"]
if type(data) is dict and name in data:
return data[name]
elif type(data) is QueryDict:
print("QUERYDICT")
return data.getlist(name)
return []

0 comments on commit 031c68a

Please sign in to comment.