|
16 | 16 | from flask import abort, current_app, g, redirect, render_template, request, url_for |
17 | 17 | from flask_login import current_user |
18 | 18 | from invenio_base.utils import obj_or_import_string |
| 19 | +from invenio_communities.errors import CommunityDeletedError |
| 20 | +from invenio_communities.proxies import current_communities |
19 | 21 | from invenio_previewer.extensions import default as default_previewer |
20 | 22 | from invenio_previewer.proxies import current_previewer |
21 | 23 | from invenio_rdm_records.proxies import current_rdm_records |
@@ -67,11 +69,20 @@ def get_record_community(record): |
67 | 69 | ) or expanded_parent.get("communities", {}).get("default") |
68 | 70 |
|
69 | 71 | if community_review or community_default: |
70 | | - is_community_deleted = expanded_community.get("is_ghost", False) |
71 | | - if is_community_deleted: |
| 72 | + is_community_pid_deleted = expanded_community.get("is_ghost", False) |
| 73 | + if is_community_pid_deleted: |
| 74 | + # community pid is not found in search i.e its pid is deleted |
72 | 75 | return None, community_id |
73 | | - else: |
| 76 | + |
| 77 | + # resolve the community again to check the deletion status |
| 78 | + # deleted communities with tombstones are not idenitfied as ghost records |
| 79 | + # at the moment because `read_many()` function is not filtering them out |
| 80 | + try: |
| 81 | + current_communities.service.read(id_=community_id, identity=g.identity) |
| 82 | + # community has not tombstone |
74 | 83 | return expanded_community, community_id |
| 84 | + except CommunityDeletedError: |
| 85 | + return None, community_id |
75 | 86 | else: |
76 | 87 | return None, None |
77 | 88 |
|
|
0 commit comments