Skip to content

Commit

Permalink
Merge pull request #10846 from Ostap-Zherebetskyi/fix/update_Preprint…
Browse files Browse the repository at this point in the history
…OldVersionsImmutableMixin

[ENG-6720] Fixed PreprintOldVersionsImmutableMixin
  • Loading branch information
cslzchen authored Dec 12, 2024
2 parents fcc61de + 0888f31 commit 66aea3f
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 @@ -73,21 +73,21 @@ class PreprintOldVersionsImmutableMixin:
'''Override method to reject modify requests for old preprint versions (except for withdrawal)'''
def update(self, request, *args, **kwargs):
preprint = self.get_preprint(check_object_permissions=False)
if preprint.is_latest_version:
if preprint.is_latest_version or preprint.machine_state == 'initial':
return super().update(request, *args, **kwargs)

raise Conflict(detail='Edit availiabe only for the last preprint version or withdrawn preprints')

def create(self, request, *args, **kwargs):
preprint = self.get_preprint(check_object_permissions=False)
if preprint.is_latest_version:
if preprint.is_latest_version or preprint.machine_state == 'initial':
return super().create(request, *args, **kwargs)

raise Conflict(detail='Edit availiabe only for the last preprint version or withdrawn preprints')

def delete(self, request, *args, **kwargs):
preprint = self.get_preprint(check_object_permissions=False)
if preprint.is_latest_version:
if preprint.is_latest_version or preprint.machine_state == 'initial':
return super().delete(request, *args, **kwargs)

raise Conflict(detail='Edit availiabe only for the last preprint version or withdrawn preprints')
Expand Down

0 comments on commit 66aea3f

Please sign in to comment.