SciPost Code Repository

Skip to content
Snippets Groups Projects
Commit 987b4324 authored by George Katsikas's avatar George Katsikas :goat:
Browse files

allow attachment misnaming only when orphaned

parent e61342d8
No related branches found
No related tags found
No related merge requests found
......@@ -315,13 +315,13 @@ class SubsidyAttachmentForm(forms.ModelForm):
required=False,
)
def clean_attachment(self):
def clean(self):
orphaned = self.cleaned_data["subsidy"] is None
attachment = self.cleaned_data["attachment"]
existing_attachment = getattr(self.instance, "attachment", None)
# Allow already uploaded attachments
if existing_attachment and attachment is not None:
return attachment
# Allow misnamed orphans
if orphaned:
return
filename_regex = (
"^SciPost_"
......@@ -336,7 +336,6 @@ class SubsidyAttachmentForm(forms.ModelForm):
"The filename does not match the required regex pattern "
f"'{filename_regex}'",
)
return attachment
#############
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment