diff --git a/scipost_django/journals/forms.py b/scipost_django/journals/forms.py index 3b38810ffaf0dc1c857fcbc3bf305610f1e898bd..04760df64342ad60caf6a1792d614a75cf77d81b 100644 --- a/scipost_django/journals/forms.py +++ b/scipost_django/journals/forms.py @@ -191,7 +191,8 @@ class AbstractJATSForm(forms.ModelForm): class FundingInfoForm(forms.ModelForm): funding_statement = forms.CharField( - widget=forms.Textarea({"placeholder": "Paste the funding info statement here"}) + required=False, + widget=forms.Textarea({"placeholder": "Paste the funding info statement here"}), ) class Meta: diff --git a/scipost_django/journals/views.py b/scipost_django/journals/views.py index 8e09a3f321d81c13381fff620bc1413febd2eb7e..f9f4580180390d98d950a87be1bb46c554ac5295 100644 --- a/scipost_django/journals/views.py +++ b/scipost_django/journals/views.py @@ -960,6 +960,15 @@ class FundingInfoView( form_class = FundingInfoForm template_name = "journals/create_funding_info_metadata.html" + # Delete the funding statement if the form is submitted empty + def form_valid(self, form): + if form.cleaned_data.get("funding_statement", "") == "": + self.object.metadata["funding_statement"] = "" + self.object.save() + return redirect(self.get_success_url()) + + return super().form_valid(form) + @permission_required("scipost.can_draft_publication", return_403=True) @transaction.atomic