Skip to content

Commit

Permalink
Fixed few issues and updated the testbook
Browse files Browse the repository at this point in the history
  • Loading branch information
RK206 committed Oct 16, 2024
1 parent 594fc6f commit b30188e
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 10 deletions.
21 changes: 21 additions & 0 deletions doajtest/testbook/article_xml_upload/article_doaj_xml_upload.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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.
4 changes: 2 additions & 2 deletions doajtest/unit/test_tasks_ingestDOAJarticles.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
])
Expand Down Expand Up @@ -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")
])
Expand Down
13 changes: 6 additions & 7 deletions portality/bll/services/article.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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}
Expand Down Expand Up @@ -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)
Expand Down
11 changes: 11 additions & 0 deletions portality/templates-v2/public/publisher/xml_help.html
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,17 @@ <h2 id="explanations">Explanation of XML errors</h2>
Ensure that all your articles have the correct DOIs and full-text links. If it still doesn’t work please <a href="https://github.com/DOAJ/doaj/issues/new/choose" target="_blank" rel="noopener">submit a bug report</a> or <a href="{{ url_for('doaj.contact') }}">contact us</a> with the details; we may need to clean up your existing articles manually.
</td>
</tr>
<tr>
<th>
<code>Article(s) cannot be uploaded before OA start date of the Journal</code>
</th>
<td>
One or more articles in the xml has the <strong>publicationDate</strong> which is before OpenAccess start date of the Journal.
</td>
<td>
Ensure that all your articles are uploaded on or after OpenAccess start date of the Journal.
</td>
</tr>
</tbody>
</table>
{% endblock %}
2 changes: 1 addition & 1 deletion portality/ui/messages.py
Original file line number Diff line number Diff line change
Expand Up @@ -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."
Expand Down

0 comments on commit b30188e

Please sign in to comment.