diff --git a/scipost/services.py b/scipost/services.py index 17ca3811f608486fe1a580e636a07591343d1e28..31760507cb1dfd82701a54de85b1b8f46e682c82 100644 --- a/scipost/services.py +++ b/scipost/services.py @@ -80,10 +80,12 @@ class ArxivCaller: def _call_arxiv(self): url = self.query_base_url % self.identifier request = requests.get(url) - arxiv_data = feedparser.parse(request.content)['entries'][0] + response_content = feedparser.parse(request.content) + arxiv_data = response_content['entries'][0] if self._search_result_present(arxiv_data): self.is_valid = True self._arxiv_data = arxiv_data + self.metadata = response_content else: self.is_valid = False diff --git a/submissions/views.py b/submissions/views.py index a3c046f0dca97d4b7c232a9de15eea2490ac9cdd..d6258e00d531b063229a3dc319998c3804703db6 100644 --- a/submissions/views.py +++ b/submissions/views.py @@ -27,7 +27,6 @@ from .forms import SubmissionIdentifierForm, SubmissionForm, SubmissionSearchFor SubmissionCycleChoiceForm from .utils import SubmissionUtils -from journals.constants import SCIPOST_JOURNALS_SPECIALIZATIONS from scipost.forms import ModifyPersonalMessageForm, RemarkForm from scipost.models import Contributor, Remark, RegistrationInvitation from scipost.services import ArxivCaller @@ -55,14 +54,62 @@ class PrefillUsingIdentifierView(PermissionRequiredMixin, FormView): identifierform = SubmissionIdentifierForm(request.POST) if identifierform.is_valid(): # Use the ArxivCaller class to make the API calls - caller = ArxivCaller(Submission, identifierform.cleaned_data['identifier']) - caller.process() + caller = ArxivCaller(identifierform.cleaned_data['identifier']) - if caller.is_valid(): + if caller.is_valid: # Arxiv response is valid and can be shown - metadata = caller.metadata - is_resubmission = caller.resubmission + + # BUG !!! + # + # + # + # OLD VARIABLES THAT WERE ACCESSIBLE ON THE OLD CALLER, BUT NOT ON THE NEW ONE: + # + # is_resubmission + # identifier_with_vn_nr + # identifier_without_vn_nr + # previous_submissions + # version_nr + + # OLD CHECKS TO BE IMPLENTED BACK IN: + # + # + # def _check_identifier(self): + # - '''Split the given identifier in an article identifier and version number.''' + # - if not self.caller_regex: + # - raise NotImplementedError('No regex is set for this caller') + # - + # - if re.match(self.caller_regex, self.identifier): + # - self.identifier_without_vn_nr = self.identifier.rpartition('v')[0] + # - self.identifier_with_vn_nr = self.identifier + # - self.version_nr = int(self.identifier.rpartition('v')[2]) + # + # + # - def _precheck_duplicate(self): + # - '''Check if identifier for object already exists.''' + # - if self.target_object.same_version_exists(self.identifier_with_vn_nr): + # - raise ValueError('preprint_already_submitted') + # + # + # - def _precheck_previous_submissions_are_valid(self): + # - '''Check if previous submitted versions have the appropriate status.''' + # - try: + # - self.previous_submissions = self.target_object.different_versions( + # - self.identifier_without_vn_nr) + # - except AttributeError: + # - # Commentaries do not have previous version numbers? + # - pass + # - + # - if self.previous_submissions: + # - for submission in [self.previous_submissions[0]]: + # - if submission.status == 'revision_requested': + # - self.resubmission = True + # - elif submission.status in ['rejected', 'rejected_visible']: + # - raise ValueError('previous_submissions_rejected') + # - else: + # - raise ValueError('previous_submission_undergoing_refereeing') + title = metadata['entries'][0]['title'] authorlist = metadata['entries'][0]['authors'][0]['name'] for author in metadata['entries'][0]['authors'][1:]: