diff --git a/invenio_requests/services/user_moderation/service.py b/invenio_requests/services/user_moderation/service.py index 50d2717c..57d1bf51 100644 --- a/invenio_requests/services/user_moderation/service.py +++ b/invenio_requests/services/user_moderation/service.py @@ -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, diff --git a/tests/conftest.py b/tests/conftest.py index b5eaf753..2ecc8f21 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -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