diff --git a/commentaries/forms.py b/commentaries/forms.py index fd158ef1e844320d32828170c0e609905bcb846e..be071a9fb1b38374e6baf30d1d51a93c7166d0dc 100644 --- a/commentaries/forms.py +++ b/commentaries/forms.py @@ -15,6 +15,7 @@ import strings class DOIToQueryForm(forms.Form): VALID_DOI_REGEXP = r'^(?i)10.\d{4,9}/[-._;()/:A-Z0-9]+$' doi = forms.RegexField(regex=VALID_DOI_REGEXP, strip=True, help_text=strings.doi_query_help_text, + error_messages={'invalid': strings.doi_query_invalid}, widget=forms.TextInput({'label': 'DOI', 'placeholder': strings.doi_query_placeholder})) def clean_doi(self): @@ -44,8 +45,8 @@ class ArxivQueryForm(forms.Form): VALID_ARXIV_IDENTIFIER_REGEX = "(?:{})|(?:{})".format(IDENTIFIER_PATTERN_NEW, IDENTIFIER_PATTERN_OLD) identifier = forms.RegexField(regex=VALID_ARXIV_IDENTIFIER_REGEX, strip=True, - help_text=strings.arxiv_query_help_text, widget=forms.TextInput( - {'placeholder': strings.arxiv_query_placeholder})) + help_text=strings.arxiv_query_help_text, error_messages={'invalid': strings.arxiv_query_invalid}, + widget=forms.TextInput( {'placeholder': strings.arxiv_query_placeholder})) def clean_identifier(self): identifier = self.cleaned_data['identifier'] diff --git a/strings/__init__.py b/strings/__init__.py index 67211441f87a16a389af55fef305130bd0ad69bb..51115395b4c01978c62b95c036d3f9a5e7445cfc 100644 --- a/strings/__init__.py +++ b/strings/__init__.py @@ -18,6 +18,10 @@ doi_query_help_text = ( 'For published papers, you can prefill the form (except for domain, subject area and abstract) using the DOI. ' "(Give the DOI as 10.[4 to 9 digits]/[string], without prefix, as per the placeholder)." ) +doi_query_invalid = ( + "DOI does not match the expression supplied by CrossRef. Either it is very old or you made a mistake. " + "If you are sure it is correct, please enter the metadata manually. Sorry for the inconvenience." +) arxiv_query_placeholder = ( "new style: YYMM.####(#)v#(#) or " @@ -27,6 +31,7 @@ arxiv_query_help_text = ( "For preprints, you can prefill the form using the arXiv identifier. " "Give the identifier without prefix and do not forget the version number, as per the placeholder." ) +arxiv_query_invalid = 'ArXiv identifier is invalid. Did you include a version number?' # Arxiv response is not valid arxiv_caller_errormessages = {