Skip to content

Commit

Permalink
[Fixes #12170] unable to set advanced contact roles in metadata editor
Browse files Browse the repository at this point in the history
  • Loading branch information
mwallschlaeger authored and giohappy committed Apr 26, 2024
1 parent f023ceb commit 9422844
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 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
4 changes: 2 additions & 2 deletions geonode/base/widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +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:
return data.getlist(name)
return []

0 comments on commit 9422844

Please sign in to comment.