Skip to content

Commit

Permalink
modifications: marc21 service permissions
Browse files Browse the repository at this point in the history
  • Loading branch information
philippgualdi committed Jul 11, 2023
1 parent dcae11c commit 9cc3ee1
Showing 1 changed file with 26 additions and 2 deletions.
28 changes: 26 additions & 2 deletions invenio_records_marc21/services/permissions.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,34 +44,53 @@ class Marc21RecordPermissionPolicy(RecordPermissionPolicy):
can_curate = can_manage + [Marc21RecordCurators()]
can_view = can_curate

# Records
# Allow to create a record (create a draft)
can_create = can_manage
# Allow to put a record in edit mode (create a draft from record)
can_edit = can_curate
# Allow publishing a new record or changes to an existing record.
can_publish = can_curate
# Allow lifting a record or draft.
can_lift_embargo = can_curate
# Allow creating a new version of an existing published record.
can_new_version = can_manage

# Records
can_search = can_all

# Allow reading metadata of a record
can_read = [
IfRestricted("record", then_=can_view, else_=can_all),
]
# Files permissions

# Record files permissions
# Allow enabling/disabling files
can_manage_files = can_curate

can_read_files = [
IfRestricted("files", then_=can_view, else_=can_all),
]
can_get_content_files = [
IfFileIsLocal(then_=can_read_files, else_=[SystemProcess()])
]

# Allow managing record access
can_manage_record_access = can_manage

# Draft
can_read_draft = can_curate
# Allow deleting/discarding a draft and all associated files
can_delete_draft = can_curate
# Allow updating metadata of a draft
can_update_draft = can_curate
# Allow ability to search drafts
can_search_drafts = can_curate

# Draft files permissions
# Allow reading files of a draft
can_draft_read_files = can_curate
# Allow uploading, updating and deleting files in drafts
# Same permissions for files needed as draft
can_draft_create_files = can_curate
can_draft_update_files = can_curate
can_draft_delete_files = can_curate
Expand All @@ -90,6 +109,11 @@ class Marc21RecordPermissionPolicy(RecordPermissionPolicy):
can_pid_discard = can_curate
can_pid_delete = can_curate

# TODO: Add permissions for community when we add the feature!

# Allow for querying of statistics
can_query_stats = [Disable()]

# Disabled actions
can_create_files = [Disable()]
can_update_files = [Disable()]
Expand Down

0 comments on commit 9cc3ee1

Please sign in to comment.