Skip to content

Commit

Permalink
updated PreprintOldVersionsImmutableMixin checks
Browse files Browse the repository at this point in the history
Rebased and fixed concflicts
  • Loading branch information
Ostap-Zherebetskyi authored and cslzchen committed Jan 6, 2025
1 parent 0c95c7d commit 726eec1
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions api/preprints/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,23 +75,23 @@ class PreprintOldVersionsImmutableMixin:
"""
def update(self, request, *args, **kwargs):
preprint = self.get_preprint(check_object_permissions=False)
if preprint.is_latest_version or preprint.machine_state == 'initial':
if preprint.is_latest_version or preprint.machine_state in ['initial', 'pending']:
return super().update(request, *args, **kwargs)
message = f'User can not edit previous versions of a preprint: [_id={preprint._id}]'
sentry.log_message(message)
raise Conflict(detail=message)

def create(self, request, *args, **kwargs):
preprint = self.get_preprint(check_object_permissions=False)
if preprint.is_latest_version or preprint.machine_state == 'initial':
if preprint.is_latest_version or preprint.machine_state in ['initial', 'pending']:
return super().create(request, *args, **kwargs)
message = f'User can not edit previous versions of a preprint: [_id={preprint._id}]'
sentry.log_message(message)
raise Conflict(detail=message)

def destroy(self, request, *args, **kwargs):
preprint = self.get_preprint(check_object_permissions=False)
if preprint.is_latest_version or preprint.machine_state == 'initial':
if preprint.is_latest_version or preprint.machine_state == ['initial', 'pending']:
return super().destroy(request, *args, **kwargs)
message = f'User can not edit previous versions of a preprint: [_id={preprint._id}]'
sentry.log_message(message)
Expand Down

0 comments on commit 726eec1

Please sign in to comment.