From d59ecd3ab2431bac40b308d9ea7688047dccd575 Mon Sep 17 00:00:00 2001 From: "J.-S. Caux" <J.S.Caux@uva.nl> Date: Fri, 30 Apr 2021 06:57:18 +0200 Subject: [PATCH] Add check on defined_type_name --- submissions/forms.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/submissions/forms.py b/submissions/forms.py index 724581e6b..e44271d7b 100644 --- a/submissions/forms.py +++ b/submissions/forms.py @@ -180,6 +180,20 @@ def check_chemrxiv_identifier_w_vn_nr(chemrxiv_identifier_w_vn_nr): error_message = 'A preprint associated to this identifier does not exist.' raise forms.ValidationError(error_message) + # Check if the type of this resource is indeed a preprint + if 'defined_type_name' in metadata: + if metadata['defined_type_name'] != 'preprint': + error_message = ('This does not seem to be a preprint: the type ' + 'returned by ChemRxiv is %(defined_type_name)s. ' + 'Please contact techsupport.') + raise forms.ValidationError( + error_message, code='wrong_defined_type_name', + params={'defined_type_name': metadata['defined_type_name']}) + else: + raise forms.ValidationError( + 'ChemRxiv failed to return a defined_type_name. Please contact techsupport.', + code='wrong_defined_type_name') + # Check if this article has already been published (according to Figshare) published_id = None if 'resource_doi' in metadata: -- GitLab