Skip to content

Commit

Permalink
roles: changed need creation by role name to id
Browse files Browse the repository at this point in the history
  • Loading branch information
alejandromumo committed Jul 27, 2023
1 parent 06d2472 commit a783f67
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
4 changes: 2 additions & 2 deletions invenio_requests/services/user_moderation/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ def request_moderation(self, identity, topic, data=None, uow=None, **kwargs):
topic = {"user": str(topic)}

# Receiver can be configured, by default send the request to users with moderation role
receiver = {"group": role.name} # TODO to be changed to role id
creator = {"group": role.name} # TODO to be changed to role id
receiver = {"group": role.id}
creator = {"group": role.id}

request_item = self.requests_service.create(
identity,
Expand Down
7 changes: 6 additions & 1 deletion tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,12 @@ def mod_identity(app, moderator_user):
"""Admin user for requests."""
idt = Identity(moderator_user.id)
# Add Role user_moderator
idt.provides.add(RoleNeed(MODERATION_ACTION_NAME))
for role in moderator_user.roles:
if role.name == MODERATION_ACTION_NAME:
break
assert role, "Moderation role must be created and associated to the moderator user."
# We must use the role id and not its name
idt.provides.add(RoleNeed(role.id))
# Search requires user to be authenticated
idt.provides.add(Need(method="system_role", value="authenticated_user"))
return idt
Expand Down

0 comments on commit a783f67

Please sign in to comment.