Skip to content

Commit

Permalink
permissions: disable write operations when read-only mode is on
Browse files Browse the repository at this point in the history
  • Loading branch information
max-moser committed Nov 14, 2022
1 parent c9988d7 commit e7e1648
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions invenio_vocabularies/services/permissions.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# -*- coding: utf-8 -*-
#
# Copyright (C) 2020-2021 CERN.
# Copyright (C) 2022 TU Wien.
#
# Invenio-Vocabularies is free software; you can redistribute it and/or
# modify it under the terms of the MIT License; see LICENSE file for more
Expand All @@ -9,15 +10,19 @@
"""Vocabulary permissions."""

from invenio_records_permissions import RecordPermissionPolicy
from invenio_records_permissions.generators import AnyUser, SystemProcess
from invenio_records_permissions.generators import (
AnyUser,
DisableIfReadOnly,
SystemProcess,
)


class PermissionPolicy(RecordPermissionPolicy):
"""Permission policy."""

can_search = [SystemProcess(), AnyUser()]
can_read = [SystemProcess(), AnyUser()]
can_create = [SystemProcess()]
can_update = [SystemProcess()]
can_delete = [SystemProcess()]
can_manage = [SystemProcess()]
can_create = [SystemProcess(), DisableIfReadOnly()]
can_update = [SystemProcess(), DisableIfReadOnly()]
can_delete = [SystemProcess(), DisableIfReadOnly()]
can_manage = [SystemProcess(), DisableIfReadOnly()]

0 comments on commit e7e1648

Please sign in to comment.