From b30188e73cc5af5a62fd8ffefb0913f9ebc6422b Mon Sep 17 00:00:00 2001 From: Ramakrishna Sakhamuru Date: Wed, 16 Oct 2024 21:20:08 +0530 Subject: [PATCH] Fixed few issues and updated the testbook --- .../article_doaj_xml_upload.yml | 21 +++++++++++++++++++ .../unit/test_tasks_ingestDOAJarticles.py | 4 ++-- portality/bll/services/article.py | 13 ++++++------ .../public/publisher/xml_help.html | 11 ++++++++++ portality/ui/messages.py | 2 +- 5 files changed, 41 insertions(+), 10 deletions(-) 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 @@

Explanation of XML errors

Ensure that all your articles have the correct DOIs and full-text links. If it still doesn’t work please submit a bug report or contact us with the details; we may need to clean up your existing articles manually. + + + Article(s) cannot be uploaded before OA start date of the Journal + + + One or more articles in the xml has the publicationDate which is before OpenAccess start date of the Journal. + + + Ensure that all your articles are uploaded on or after OpenAccess start date of the Journal. + + {% endblock %} diff --git a/portality/ui/messages.py b/portality/ui/messages.py index c974419d9..f3f2d80c1 100644 --- a/portality/ui/messages.py +++ b/portality/ui/messages.py @@ -68,7 +68,7 @@ class Messages(object): EXCEPTION_IDENTICAL_PISSN_AND_EISSN = "The Print and Online ISSNs supplied are identical. If you supply two ISSNs, they must be different." EXCEPTION_NO_ISSNS = "Neither the Print ISSN nor Online ISSN have been supplied. DOAJ requires at least one ISSN." EXCEPTION_INVALID_BIBJSON = "Invalid article bibjson: " # + Dataobj exception message - EXCEPTION_ARTICLE_BEFORE_OA_START_DATE = "Article '{title}' cannot be uploaded before OA start date of the Journal" + EXCEPTION_ARTICLE_BEFORE_OA_START_DATE = "Article(s) '{title}' cannot be uploaded before OA start date of the Journal" EXCEPTION_IDENTIFIER_CHANGE_CLASH = "DOI or Fulltext URL has been changed to match another article that already exists in DOAJ" EXCEPTION_IDENTIFIER_CHANGE = "Either the DOI or Fulltext URL has been changed. This operation is not permitted; please contact an administrator for help."