From cba258049a1e14acc3882d516e05e23815e60c0e Mon Sep 17 00:00:00 2001 From: Benjamin Moody Date: Tue, 6 Aug 2024 16:30:17 -0400 Subject: [PATCH] InvitationResponseForm: disallow adding editor as an author. Adding the project's editor as an author should not be allowed. (This would normally only be possible if the project is in NEEDS_RESUBMISSION state.) It would be better to have a way of completely un-assigning the editor, but the current system doesn't have a way to handle that (AssignEditorForm requires the project to be in NEEDS_ASSIGNMENT state.) --- physionet-django/project/forms.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/physionet-django/project/forms.py b/physionet-django/project/forms.py index 82283d0d9..229dfb1e9 100644 --- a/physionet-django/project/forms.py +++ b/physionet-django/project/forms.py @@ -1032,8 +1032,17 @@ def clean(self): raise forms.ValidationError( 'You are not invited.') - if cleaned_data['response'] and not cleaned_data.get('affiliation'): - raise forms.ValidationError('You must specify your affiliation.') + if cleaned_data['response']: + if self.user == self.instance.project.editor: + raise forms.ValidationError( + 'You must reassign this project to another editor ' + 'before accepting an authorship invitation.' + ) + + if not cleaned_data.get('affiliation'): + raise forms.ValidationError( + 'You must specify your affiliation.' + ) return cleaned_data