diff --git a/api/preprints/views.py b/api/preprints/views.py index 436249fb0bf..2fa938884b7 100644 --- a/api/preprints/views.py +++ b/api/preprints/views.py @@ -8,10 +8,11 @@ from framework import sentry from framework.auth.oauth_scopes import CoreScopes from osf.models import ( - ReviewAction, + Institution, Preprint, PreprintContributor, - Institution, + ReviewAction, + VersionedGuidMixin, ) from osf.utils.requests import check_select_for_update @@ -76,12 +77,14 @@ class PreprintOldVersionsImmutableMixin: @staticmethod def is_edit_allowed(preprint): - return True if any([ - preprint.is_latest_version, - preprint.machine_state in ['initial', 'rejected'], - preprint.provider.reviews_workflow == Workflows.PRE_MODERATION.value and - preprint.machine_state == 'pending', - ]) else False + if preprint.is_latest_version or preprint.machine_state == 'initial': + return True + if preprint.provider.reviews_workflow == Workflows.PRE_MODERATION.value: + if preprint.machine_state == 'pending': + return True + if preprint.machine_state == 'rejected' and preprint.version == VersionedGuidMixin.INITIAL_VERSION_NUMBER: + return True + return False def handle_request(self, request, method, *args, **kwargs): preprint = self.get_preprint(check_object_permissions=False) diff --git a/api_tests/users/views/test_user_actions.py b/api_tests/users/views/test_user_actions.py index 1236f70cc23..568574f5417 100644 --- a/api_tests/users/views/test_user_actions.py +++ b/api_tests/users/views/test_user_actions.py @@ -170,7 +170,6 @@ def test_bad_requests(self, app, url, preprint, provider, moderator): ('initial', 'accept'), ('initial', 'edit_comment'), ('initial', 'reject'), - ('pending', 'submit'), ('rejected', 'reject'), ('rejected', 'submit'), ], diff --git a/osf/models/preprint.py b/osf/models/preprint.py index af689522eea..15d8c3c0930 100644 --- a/osf/models/preprint.py +++ b/osf/models/preprint.py @@ -429,7 +429,7 @@ def create_version(cls, create_from_guid, auth): preprint.save(guid_ready=True, first_save=True) # Add contributors - for contributor in latest_version.contributor_set.exclude(user=latest_version.creator): + for contributor in latest_version.contributor_set.exclude(user=preprint.creator): try: preprint.add_contributor( contributor.user,