|
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.
|
|
16 | 17 | )
|
17 | 18 | from invenio_i18n import lazy_gettext as _
|
18 | 19 | from invenio_notifications.services.uow import NotificationOp
|
19 |
| -from invenio_pidstore.errors import PIDDoesNotExistError |
| 20 | +from invenio_pidstore.errors import PIDDoesNotExistError, PIDUnregistered |
20 | 21 | from invenio_records_resources.services import (
|
21 | 22 | RecordIndexerMixin,
|
22 | 23 | Service,
|
@@ -65,6 +66,11 @@ def record_cls(self):
|
65 | 66 | """Factory for creating a record class."""
|
66 | 67 | return self.config.record_cls
|
67 | 68 |
|
| 69 | + @property |
| 70 | + def draft_cls(self): |
| 71 | + """Factory for creating a draft class.""" |
| 72 | + return self.config.draft_cls |
| 73 | + |
68 | 74 | def _exists(self, community_id, record):
|
69 | 75 | """Return the request id if an open request already exists, else None."""
|
70 | 76 | results = current_requests_service.search(
|
@@ -246,7 +252,10 @@ def search(
|
246 | 252 | **kwargs,
|
247 | 253 | ):
|
248 | 254 | """Search for record's communities."""
|
249 |
| - record = self.record_cls.pid.resolve(id_) |
| 255 | + try: |
| 256 | + record = self.record_cls.pid.resolve(id_) |
| 257 | + except PIDUnregistered: |
| 258 | + record = self.draft_cls.pid.resolve(id_, registered_only=False) |
250 | 259 | self.require_permission(identity, "read", record=record)
|
251 | 260 |
|
252 | 261 | communities_ids = record.parent.communities.ids
|
|
0 commit comments