Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix PATCH request bug in update deposit permission #1932

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 17 additions & 17 deletions b2share/modules/deposit/permissions.py
Original file line number Diff line number Diff line change
Expand Up @@ -315,23 +315,23 @@ def _load_additional_permissions(self):
state_permission.explicit_needs.add(UserNeed(owner_id))
permissions.append(state_permission)

# Create permission for updating generic metadata fields.
# Only superadmin can modify published draft.
if self.deposit['publication_state'] != 'published':
new_state = new_deposit['publication_state']
# Check if any metadata has been changed
del new_deposit['publication_state']
original_metadata = deepcopy(self.deposit)
del original_metadata['publication_state']
if original_metadata != new_deposit:
permissions.append(
UpdateDepositMetadataPermission(self.deposit, new_state)
)

if external_pids_changed:
permissions.append(
DepositFilesPermission(self.deposit, 'bucket-update')
)
# Create permission for updating generic metadata fields.
# Only superadmin can modify published draft.
if self.deposit['publication_state'] != 'published':
new_state = new_deposit['publication_state']
# Check if any metadata has been changed
del new_deposit['publication_state']
original_metadata = deepcopy(self.deposit)
del original_metadata['publication_state']
if original_metadata != new_deposit:
permissions.append(
UpdateDepositMetadataPermission(self.deposit, new_state)
)

if external_pids_changed:
permissions.append(
DepositFilesPermission(self.deposit, 'bucket-update')
)

if len(permissions) > 1:
self.permissions.add(AndPermissions(*permissions))
Expand Down