From f4576551b7bf5931e187694d23282e1ffe6d0a6c Mon Sep 17 00:00:00 2001 From: Benjamin Moody Date: Wed, 14 Aug 2024 17:22:11 -0400 Subject: [PATCH 1/2] CopyeditForm: fail if project has integrity errors. If a project has been submitted and is in "awaiting copyedit" stage, and the project contains integrity errors (either because there are errors that weren't caught at submission time, or because the editor changed something that causes an error), then the editor should be required to fix those errors before the project can be advanced to "awaiting author approval". --- physionet-django/console/forms.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/physionet-django/console/forms.py b/physionet-django/console/forms.py index 758a4b90c..fd9c2b74b 100644 --- a/physionet-django/console/forms.py +++ b/physionet-django/console/forms.py @@ -281,6 +281,9 @@ def __init__(self, *args, **kwargs): def clean(self): if self.errors: return + project = self.instance.project + if not project.check_integrity(): + raise forms.ValidationError(project.integrity_errors) if self.cleaned_data['made_changes'] and not self.cleaned_data['changelog_summary']: raise forms.ValidationError('Describe the changes you made.') if not self.cleaned_data['made_changes'] and self.cleaned_data['changelog_summary']: From 852332bc1232204c6b14b0c67a56b40c634432db Mon Sep 17 00:00:00 2001 From: Benjamin Moody Date: Wed, 14 Aug 2024 17:34:17 -0400 Subject: [PATCH 2/2] Test that integrity errors prevent completing copyedit. If a submitted project contains integrity errors (such as a required field being blank), then the editor should be required to fix those errors during the "awaiting copyedit" stage, before the project can be advanced to "awaiting author approval". --- physionet-django/console/test_views.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/physionet-django/console/test_views.py b/physionet-django/console/test_views.py index bb54b8199..1485e76d6 100644 --- a/physionet-django/console/test_views.py +++ b/physionet-django/console/test_views.py @@ -213,6 +213,27 @@ def test_copyedit(self): data={'reopen_copyedit':''}) project = ActiveProject.objects.get(id=project.id) self.assertTrue(project.copyeditable()) + + # Erase a required field + project.refresh_from_db() + project.abstract = '' + project.save() + + # "Complete copyedit" should fail because abstract is missing + response = self.client.post( + reverse('copyedit_submission', args=(project.slug,)), data={ + 'complete_copyedit': '', + 'made_changes': 1, + 'changelog_summary': 'Removed abstract', + }) + project.refresh_from_db() + self.assertTrue(project.copyeditable()) + + # Restore abstract + project.refresh_from_db() + project.abstract = '

Database of annotated ECGs

' + project.save() + # Recomplete copyedit response = self.client.post(reverse( 'copyedit_submission', args=(project.slug,)),