Skip to content

Commit ba46be7

Browse files
committed
service: permission: add unlisted tag check for can_search
1 parent 407db1f commit ba46be7

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

invenio_vocabularies/services/generators.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ def __init__(self, tags, then_, else_):
2727

2828
def _condition(self, record=None, **kwargs):
2929
"""Check if the record has the tags."""
30+
if not record:
31+
return False
3032
return any(tag in record.get("tags", []) for tag in self.tags)
3133

3234
def query_filter(self, **kwargs):

invenio_vocabularies/services/permissions.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,10 @@
1717
class PermissionPolicy(RecordPermissionPolicy):
1818
"""Permission policy."""
1919

20-
can_search = [SystemProcess(), AnyUser()]
20+
can_search = [
21+
SystemProcess(),
22+
IfTags(["unlisted"], then_=[SystemProcess()], else_=[AnyUser()]),
23+
]
2124
can_read = [
2225
SystemProcess(),
2326
IfTags(["unlisted"], then_=[SystemProcess()], else_=[AnyUser()]),

0 commit comments

Comments
 (0)