|
1 | 1 | # -*- coding: utf-8 -*-
|
2 | 2 | #
|
3 | 3 | # Copyright (C) 2023-2024 CERN.
|
4 |
| -# Copyright (C) 2024 Graz University of Technology. |
| 4 | +# Copyright (C) 2024 Graz University of Technology. |
| 5 | +# Copyright (C) 2024 KTH Royal Institute of Technology. |
5 | 6 | #
|
6 | 7 | # Invenio-RDM-Records is free software; you can redistribute it and/or modify
|
7 | 8 | # it under the terms of the MIT License; see LICENSE file for more details.
|
|
17 | 18 | )
|
18 | 19 | from invenio_i18n import lazy_gettext as _
|
19 | 20 | from invenio_notifications.services.uow import NotificationOp
|
20 |
| -from invenio_pidstore.errors import PIDDoesNotExistError |
| 21 | +from invenio_pidstore.errors import PIDDoesNotExistError, PIDUnregistered |
21 | 22 | from invenio_records_resources.services import (
|
22 | 23 | RecordIndexerMixin,
|
23 | 24 | Service,
|
@@ -67,6 +68,11 @@ def record_cls(self):
|
67 | 68 | """Factory for creating a record class."""
|
68 | 69 | return self.config.record_cls
|
69 | 70 |
|
| 71 | + @property |
| 72 | + def draft_cls(self): |
| 73 | + """Factory for creating a draft class.""" |
| 74 | + return self.config.draft_cls |
| 75 | + |
70 | 76 | def _exists(self, community_id, record):
|
71 | 77 | """Return the request id if an open request already exists, else None."""
|
72 | 78 | results = current_requests_service.search(
|
@@ -264,7 +270,10 @@ def search(
|
264 | 270 | **kwargs,
|
265 | 271 | ):
|
266 | 272 | """Search for record's communities."""
|
267 |
| - record = self.record_cls.pid.resolve(id_) |
| 273 | + try: |
| 274 | + record = self.record_cls.pid.resolve(id_) |
| 275 | + except PIDUnregistered: |
| 276 | + record = self.draft_cls.pid.resolve(id_, registered_only=False) |
268 | 277 | self.require_permission(identity, "read", record=record)
|
269 | 278 |
|
270 | 279 | communities_ids = record.parent.communities.ids
|
|
0 commit comments