From 54acecadea5e97494cdb0aeec72de9930e2e2a2b Mon Sep 17 00:00:00 2001 From: Ihor Sokhan Date: Thu, 1 May 2025 16:48:55 +0300 Subject: [PATCH] added share update on preprint withdrawal --- admin_tests/preprints/test_views.py | 9 ++++++++- osf/models/preprint.py | 2 ++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/admin_tests/preprints/test_views.py b/admin_tests/preprints/test_views.py index 06ec5fa8d04..1273a3a6363 100644 --- a/admin_tests/preprints/test_views.py +++ b/admin_tests/preprints/test_views.py @@ -536,7 +536,8 @@ def withdrawal_request(self, preprint, submitter): withdrawal_request.run_submit(submitter) return withdrawal_request - def test_can_approve_withdrawal_request(self, withdrawal_request, submitter, preprint, admin): + @mock.patch('osf.models.preprint.update_or_enqueue_on_preprint_updated') + def test_can_approve_withdrawal_request(self, mocked_function, withdrawal_request, submitter, preprint, admin): assert withdrawal_request.machine_state == DefaultStates.PENDING.value original_comment = withdrawal_request.comment @@ -552,6 +553,12 @@ def test_can_approve_withdrawal_request(self, withdrawal_request, submitter, pre assert withdrawal_request.machine_state == DefaultStates.ACCEPTED.value assert original_comment == withdrawal_request.target.withdrawal_justification + # share update is triggered when update "date_withdrawn" and "withdrawal_justification" throughout withdrawal process + updated_fields = mocked_function.call_args[1]['saved_fields'] + assert 'date_withdrawn' in updated_fields + assert 'withdrawal_justification' in updated_fields + assert preprint.SEARCH_UPDATE_FIELDS.intersection(updated_fields) + def test_can_reject_withdrawal_request(self, withdrawal_request, admin, preprint): assert withdrawal_request.machine_state == DefaultStates.PENDING.value diff --git a/osf/models/preprint.py b/osf/models/preprint.py index cfe6e56afe6..ed8aa0af380 100644 --- a/osf/models/preprint.py +++ b/osf/models/preprint.py @@ -201,6 +201,8 @@ class Preprint(DirtyFieldsMixin, VersionedGuidMixin, IdentifierMixin, Reviewable 'primary_file', 'contributors', 'tags', + 'date_withdrawn', + 'withdrawal_justification' } PREREG_LINK_INFO_CHOICES = [('prereg_designs', 'Pre-registration of study designs'),