diff --git a/doajtest/testbook/article_xml_upload/article_doaj_xml_upload.yml b/doajtest/testbook/article_xml_upload/article_doaj_xml_upload.yml index 37852ae30..e506d8769 100644 --- a/doajtest/testbook/article_xml_upload/article_doaj_xml_upload.yml +++ b/doajtest/testbook/article_xml_upload/article_doaj_xml_upload.yml @@ -357,3 +357,24 @@ tests: - Related background job is found - status is "complete" - Outcome Status is "success" + +- title: Upload a file before OA start date of the Journal + context: + role: publisher + steps: + - step: Make sure the OA start date of the journal in in future + - step: Go to the "Upload Article XML" tab in the "Publisher Area" + - step: Select "Choose file" and select the test resource file "no_issn.xml" + resource: /xml_upload_test_package/DOAJ/successful.xml + - step: Click "Upload" + results: + - 'A flash message appears at the top of the screen indicating a successful upload: + File uploaded and waiting to be processed. Check back here for updates.(Dismiss)' + - Your file is shown in the "History of uploads" with status "pending" + - step: wait a short amount of time for the job to process, then reload the page + (do not re-submit the form data). If the job remains in "pending", reload the + page until the status changes. + results: + - Your file is shown in the "History of uploads" with status "processing failed" + and a entry in the "Notes" and reads as 'Article(s) cannot be uploaded before OA start date of the Journal'. Check that the explanation link goes to + a suitable reason and resolution for the problem. \ No newline at end of file diff --git a/doajtest/unit/test_tasks_ingestDOAJarticles.py b/doajtest/unit/test_tasks_ingestDOAJarticles.py index 77f5914b1..24759f3b3 100644 --- a/doajtest/unit/test_tasks_ingestDOAJarticles.py +++ b/doajtest/unit/test_tasks_ingestDOAJarticles.py @@ -1051,7 +1051,7 @@ def test_61_journal_not_indoaj(self): def test_62_article_before_oa_start(self): journal = article_upload_tester.create_simple_journal("testowner", pissn="1234-5678", eissn="9876-5432") - journal.bibjson().oa_start = dates.now().year + 2 + journal.bibjson().oa_start = dates.now().year helpers.save_all_block_last([ journal, article_upload_tester.create_simple_publisher("testowner") ]) @@ -1088,7 +1088,7 @@ def test_62_article_before_oa_start(self): def test_63_article_after_oa_start(self): journal = article_upload_tester.create_simple_journal("testowner", pissn="1234-5678", eissn="9876-5432") - journal.bibjson().oa_start = dates.now().year - 2 + journal.bibjson().oa_start = 2013 helpers.save_all_block_last([ journal, article_upload_tester.create_simple_publisher("testowner") ]) diff --git a/portality/bll/services/article.py b/portality/bll/services/article.py index 7bcbb8952..ae6b9848f 100644 --- a/portality/bll/services/article.py +++ b/portality/bll/services/article.py @@ -72,8 +72,10 @@ def batch_create_articles(self, articles, account, duplicate_check=True, merge_d except (exceptions.ArticleMergeConflict, exceptions.ConfigurationException): raise exceptions.IngestException(message=Messages.EXCEPTION_ARTICLE_BATCH_CONFLICT) except exceptions.ArticleBeforeOAStartDate as e: + all_before_oa_start_date.add(article.bibjson().title) + result = {'fail': 1} + e.message = e.message.format(title=",".join(list(all_before_oa_start_date))) e_not_acceptable = e - result = {'fail': 1, 'before_oa_start_date': article.bibjson().title} except exceptions.ArticleNotAcceptable as e: # The ArticleNotAcceptable exception is a superset of reasons we can't match a journal to this article e_not_acceptable = e @@ -86,9 +88,6 @@ def batch_create_articles(self, articles, account, duplicate_check=True, merge_d all_shared.update(result.get("shared", set())) all_unowned.update(result.get("unowned", set())) all_unmatched.update(result.get("unmatched", set())) - article_before_oa_start = result.get("before_oa_start_date") - if isinstance(article_before_oa_start, str) and article_before_oa_start: - all_before_oa_start_date.add(article_before_oa_start) report = {"success": success, "fail": fail, "update": update, "new": new, "shared": all_shared, "unowned": all_unowned, "unmatched": all_unmatched, "before_oa_start_date":all_before_oa_start_date} @@ -244,10 +243,10 @@ def create_article(self, article, account, duplicate_check=True, merge_duplicate # Check if article is uploaded before OA start date of Journal and reject the article journal = article.get_journal() + published_year = int(article.bibjson().year) oa_start_date = journal.has_oa_start_date() - if oa_start_date and dates.now().year < oa_start_date: - raise exceptions.ArticleBeforeOAStartDate(message=Messages.EXCEPTION_ARTICLE_BEFORE_OA_START_DATE. - format(title=article.bibjson().title)) + if oa_start_date and published_year < oa_start_date: + raise exceptions.ArticleBeforeOAStartDate(message=Messages.EXCEPTION_ARTICLE_BEFORE_OA_START_DATE) if add_journal_info: article.add_journal_metadata(j=journal) diff --git a/portality/templates-v2/public/publisher/xml_help.html b/portality/templates-v2/public/publisher/xml_help.html index 91549f5be..7bf94b332 100644 --- a/portality/templates-v2/public/publisher/xml_help.html +++ b/portality/templates-v2/public/publisher/xml_help.html @@ -226,6 +226,17 @@
Article(s) cannot be uploaded before OA start date of the Journal
+