From ea64816c4a99f5f3f0650f960b8d23487c540520 Mon Sep 17 00:00:00 2001 From: philip Date: Wed, 2 Aug 2023 13:06:20 +0100 Subject: [PATCH 1/3] new url for articles --- doajtest/unit/test_toc.py | 113 +-- portality/templates/doaj/toc.html | 810 +++++++++------------ portality/templates/doaj/toc_articles.html | 44 ++ portality/templates/layouts/toc_base.html | 147 ++++ portality/view/doaj.py | 99 +-- 5 files changed, 659 insertions(+), 554 deletions(-) create mode 100644 portality/templates/doaj/toc_articles.html create mode 100644 portality/templates/layouts/toc_base.html diff --git a/doajtest/unit/test_toc.py b/doajtest/unit/test_toc.py index bfe6564d8c..b58b20445f 100644 --- a/doajtest/unit/test_toc.py +++ b/doajtest/unit/test_toc.py @@ -1,16 +1,57 @@ -from doajtest.helpers import DoajTestCase from doajtest.fixtures import ArticleFixtureFactory, JournalFixtureFactory +from doajtest.helpers import DoajTestCase +from portality import app as _app # noqa, make sure route is registered from portality import models +from portality.util import url_for + + +def test_toc_uses_both_issns_when_available(app_test, url_name): + j = models.Journal(**JournalFixtureFactory.make_journal_source(in_doaj=True)) + pissn = j.bibjson().first_pissn + eissn = j.bibjson().first_eissn + j.set_last_manual_update() + j.save(blocking=True) + a = models.Article(**ArticleFixtureFactory.make_article_source(pissn=pissn, eissn=eissn, in_doaj=True)) + a.save(blocking=True) + with app_test.test_client() as t_client: + response = t_client.get(url_for(url_name, identifier=j.bibjson().get_preferred_issn())) + assert response.status_code == 200 + assert pissn in response.data.decode() + assert eissn in response.data.decode() + + +def toc_correctly_uses_pissn(app_test, url_name): + j = models.Journal(**JournalFixtureFactory.make_journal_source(in_doaj=True)) + pissn = j.bibjson().first_pissn + # remove eissn + del j.bibjson().eissn + j.set_last_manual_update() + j.save(blocking=True) + a = models.Article(**ArticleFixtureFactory.make_article_source(pissn=pissn, in_doaj=True)) + a.save(blocking=True) + with app_test.test_client() as t_client: + response = t_client.get(url_for(url_name, identifier=j.bibjson().get_preferred_issn())) + assert response.status_code == 200 + assert pissn in response.data.decode() + + +def toc_correctly_uses_eissn(app_test, url_name): + j = models.Journal(**JournalFixtureFactory.make_journal_source(in_doaj=True)) + eissn = j.bibjson().first_eissn + # remove pissn + del j.bibjson().pissn + j.set_last_manual_update() + j.save(blocking=True) + a = models.Article(**ArticleFixtureFactory.make_article_source(pissn=eissn, in_doaj=True)) + a.save(blocking=True) + with app_test.test_client() as t_client: + response = t_client.get(url_for(url_name, identifier=j.bibjson().get_preferred_issn())) + assert response.status_code == 200 + assert eissn in response.data.decode() class TestTOC(DoajTestCase): - def setUp(self): - super(TestTOC, self).setUp() - - def tearDown(self): - super(TestTOC, self).tearDown() - def test_01_article_index_date_parsing(self): """ The ToC date histogram needs an accurate datestamp in the article's index """ a = models.Article(**ArticleFixtureFactory.make_article_source()) @@ -43,9 +84,9 @@ def test_01_article_index_date_parsing(self): d = a.bibjson().get_publication_date() assert d == '2012-03-01T00:00:00Z' - a.bibjson().year = '86' # beware: this test will give a false negative 70 years from - a.bibjson().month = '11' # the time of writing; this gives adequate warning (24 years) - d = a.bibjson().get_publication_date() # to fix hard-coding of centuries in get_publication_date(). + a.bibjson().year = '86' # beware: this test will give a false negative 70 years from + a.bibjson().month = '11' # the time of writing; this gives adequate warning (24 years) + d = a.bibjson().get_publication_date() # to fix hard-coding of centuries in get_publication_date(). assert d == '1986-11-01T00:00:00Z' # Check we can handle numeric months @@ -90,45 +131,21 @@ def test_02_toc_requirements(self): assert a.data['index']['date_toc_fv_month'] == a.data['index']['date'] == "1991-01-01T00:00:00Z" def test_03_toc_uses_both_issns_when_available(self): - j = models.Journal(**JournalFixtureFactory.make_journal_source(in_doaj=True)) - pissn = j.bibjson().first_pissn - eissn = j.bibjson().first_eissn - j.set_last_manual_update() - j.save(blocking=True) - a = models.Article(**ArticleFixtureFactory.make_article_source(pissn=pissn, eissn=eissn, in_doaj=True)) - a.save(blocking=True) - with self.app_test.test_client() as t_client: - response = t_client.get('/toc/{}'.format(j.bibjson().get_preferred_issn())) - assert response.status_code == 200 - assert pissn in response.data.decode() - assert eissn in response.data.decode() + test_toc_uses_both_issns_when_available(self.app_test, 'doaj.toc') + + def test_04_toc_correctly_uses_pissn(self): + toc_correctly_uses_pissn(self.app_test, 'doaj.toc') + + def test_05_toc_correctly_uses_eissn(self): + toc_correctly_uses_eissn(self.app_test, 'doaj.toc') + + +class TestTOCArticles(DoajTestCase): + def test_03_toc_uses_both_issns_when_available(self): + test_toc_uses_both_issns_when_available(self.app_test, 'doaj.toc_articles') def test_04_toc_correctly_uses_pissn(self): - j = models.Journal(**JournalFixtureFactory.make_journal_source(in_doaj=True)) - pissn = j.bibjson().first_pissn - # remove eissn - del j.bibjson().eissn - - j.set_last_manual_update() - j.save(blocking=True) - a = models.Article(**ArticleFixtureFactory.make_article_source(pissn=pissn, in_doaj=True)) - a.save(blocking=True) - with self.app_test.test_client() as t_client: - response = t_client.get('/toc/{}'.format(j.bibjson().get_preferred_issn())) - assert response.status_code == 200 - assert pissn in response.data.decode() + toc_correctly_uses_pissn(self.app_test, 'doaj.toc_articles') def test_05_toc_correctly_uses_eissn(self): - j = models.Journal(**JournalFixtureFactory.make_journal_source(in_doaj=True)) - eissn = j.bibjson().first_eissn - # remove pissn - del j.bibjson().pissn - - j.set_last_manual_update() - j.save(blocking=True) - a = models.Article(**ArticleFixtureFactory.make_article_source(pissn=eissn, in_doaj=True)) - a.save(blocking=True) - with self.app_test.test_client() as t_client: - response = t_client.get('/toc/{}'.format(j.bibjson().get_preferred_issn())) - assert response.status_code == 200 - assert eissn in response.data.decode() + toc_correctly_uses_eissn(self.app_test, 'doaj.toc_articles') diff --git a/portality/templates/doaj/toc.html b/portality/templates/doaj/toc.html index acf0077a7e..14872aa014 100644 --- a/portality/templates/doaj/toc.html +++ b/portality/templates/doaj/toc.html @@ -1,487 +1,367 @@ -{% extends "layouts/public_base.html" %} - -{% block body_class %} - journal-details -{% endblock %} - -{% block page_title %}{% include "doaj/includes/_journal_meta_title.html" %}{% endblock %} -{% block meta_og_title %}{% include "doaj/includes/_journal_meta_title.html" %}{% endblock %} -{% block meta_twitter_title %}{% include "doaj/includes/_journal_meta_title.html" %}{% endblock %} -{%- block meta_description -%}{% include "doaj/includes/_journal_meta_description.html" %}{%- endblock -%} -{%- block meta_og_description -%}{% include "doaj/includes/_journal_meta_description.html" %}{%- endblock -%} -{%- block meta_twitter_description -%}{% include "doaj/includes/_journal_meta_description.html" %}{%- endblock -%} - -{% block content %} - - {%- - set CC_MAP = { - "CC BY" : ["https://creativecommons.org/licenses/by/4.0/", ["by"]], - "CC BY-NC" : ["https://creativecommons.org/licenses/by-nc/4.0/", ["by", "nc"]], - "CC BY-NC-ND" : ["https://creativecommons.org/licenses/by-nc-nd/4.0/", ["by", "nc", "nd"]], - "CC BY-NC-SA" : ["https://creativecommons.org/licenses/by-nc-sa/4.0/", ["by", "nc", "sa"]], - "CC BY-ND" : ["https://creativecommons.org/licenses/by-nd/4.0/", ["by", "nd"]], - "CC BY-SA" : ["https://creativecommons.org/licenses/by-sa/4.0/", ["by", "sa"]], - "Public Domain" : ["https://creativecommons.org/publicdomain/zero/1.0/", ["zero"]], - } - -%} - - {% - set TYN = { - True : "Yes", - "True": "Yes", - False : "No", - "False": "No" - } - %} - - {% - set DEPOSIT_POLICY_MAP = { - "Sherpa/Romeo" : "https://v2.sherpa.ac.uk/cgi/search/publication/basic?publication_title-auto=", - "Diadorim" : "https://diadorim.ibict.br/simple-search?query=", - "Dulcinea" : "https://www.accesoabierto.net/dulcinea/lista/REVISTA/", - } - %} - -
-
- {% if journal.last_manually_updated_since(days=30) %} - - - Updated recently - - {% endif %} -

- - {{ bibjson.title }} - {% if bibjson.alternative_title %} - - {% endif %} - - {%- set seal = journal.has_seal() -%} - {%- if seal -%} - - {%- endif %} -

-

- - - {# this next bit has to be all on one line so that the spacing is correct #} - {% if bibjson.pissn %}{{bibjson.pissn}} (Print){% endif %}{% if bibjson.eissn %}{% if bibjson.pissn %} / {% endif %}{{bibjson.eissn}} (Online){% endif %} - -

- - {% if bibjson.discontinued_date %} -

Ceased publication on {{ bibjson.discontinued_datestamp.strftime("%d %B %Y") }}

- {% endif %} - - {% if past %} -

Continues - {% for p in past %} - {% set bibjson = p.bibjson() %} - {% if bibjson.issns()|length > 0 %} - {% if p.is_in_doaj() %} - {{ bibjson.title }} +{% extends "layouts/toc_base.html" %} + +{% block toc_content %} + {% set CC_MAP = { + "CC BY" : ["https://creativecommons.org/licenses/by/4.0/", ["by"]], + "CC BY-NC" : ["https://creativecommons.org/licenses/by-nc/4.0/", ["by", "nc"]], + "CC BY-NC-ND" : ["https://creativecommons.org/licenses/by-nc-nd/4.0/", ["by", "nc", "nd"]], + "CC BY-NC-SA" : ["https://creativecommons.org/licenses/by-nc-sa/4.0/", ["by", "nc", "sa"]], + "CC BY-ND" : ["https://creativecommons.org/licenses/by-nd/4.0/", ["by", "nd"]], + "CC BY-SA" : ["https://creativecommons.org/licenses/by-sa/4.0/", ["by", "sa"]], + "Public Domain" : ["https://creativecommons.org/publicdomain/zero/1.0/", ["zero"]], + } %} + + {% set DEPOSIT_POLICY_MAP = { + "Sherpa/Romeo" : "https://v2.sherpa.ac.uk/cgi/search/publication/basic?publication_title-auto=", + "Diadorim" : "https://diadorim.ibict.br/simple-search?query=", + "Dulcinea" : "https://www.accesoabierto.net/dulcinea/lista/REVISTA/", + } %} + + + +

+

About

+
+
+

Publishing with this journal

+ +
+ +
+ {% if not bibjson.apc_url and not bibjson.other_charges_url and not bibjson.waiver_url %} +

Information on publication charges not available for this journal.

+ + {% else %} + {# APCs #} + {% if bibjson.apc %} +

The journal charges up to:

+
    + {% for apc in bibjson.apc %} +
  • + {{ apc.get("price", "price unknown") }} {{ apc.get("currency", " currency unknown") }} +
  • + {% endfor %} +
+

as {% if bibjson.apc_url %} + {% endif %} + publication fees{% if bibjson.apc_url %}{% endif %} (article processing charges + or APCs) + {%- if bibjson.has_other_charges %} + and there are + {% if bibjson.other_charges_url %} + + other charges + + {%- else %} + other charges + {%- endif -%} + {% endif -%} + .

{% else %} - {{ bibjson.title }}, ISSN: {{ bibjson.get_preferred_issn() }} (not available in DOAJ) +

There are no publication fees (article processing + charges or APCs) to publish with this journal + {%- if bibjson.has_other_charges %} + but there are + {% if bibjson.other_charges_url %} + + other charges + + {% else %} + other charges + {% endif %} + {% endif -%} + .

{% endif %} - {% endif %} - {% if not loop.last %}; {% endif %} - {% endfor %} -

- {% endif %} - {% if future %} -

Continued by - {% for f in future %} - {% set bibjson = f.bibjson() %} - {% if bibjson.issns()|length > 0 %} - {% if f.is_in_doaj() %} - {{ bibjson.title }} - {% else %} - {{ bibjson.title }}, ISSN: {{ bibjson.get_preferred_issn() }} (not available in DOAJ) + {# Waivers #} + {% if bibjson.waiver_url %} +

There is a waiver + policy for these charges.

+ {% elif bibjson.apc or bibjson.has_other_charges and not bibjson.waiver_url %} +

There is no waiver policy for these charges.

{% endif %} {% endif %} - {% if not loop.last %}; {% endif %} - {% endfor %} -

- {% endif %} - - -
- -
- - -
-
-

About

-
-
-

Publishing with this journal

- -
- -
- {% if not bibjson.apc_url and not bibjson.other_charges_url and not bibjson.waiver_url %} -

Information on publication charges not available for this journal.

- +
+
+ +
+ +
+

Look up the journal’s:

+
-
+ {% if bibjson.editorial_review_url %}{% endif %} + + {% endif %} + - + + {% if bibjson.publication_time_weeks %} +
+ +
+ Expect on average {{ bibjson.publication_time_weeks }} weeks from + submission to publication. +
+
+ {% endif %} +
+ +
+

Best practice

+
+ +
+ {%- set oa_start = journal.has_oa_start_date() -%} + {% if oa_start %} +

+ This journal began publishing in open access in {{ oa_start }}. + + + What does DOAJ define as Open Accesss? + +

+ {%- endif %} + {% if bibjson.licenses %} +

This journal uses + {% for license in bibjson.licenses %} + {%- if loop.last and bibjson.licenses|length > 1 -%} or + {%- elif not loop.first -%}, {%- endif -%} + {% if license.type == "Publisher's own license" %} their + publisher’s own + {% else %} a {{ license.type }} + {%- endif -%} + {% endfor %} + license. +

+

+ {% for license in bibjson.licenses %} + {% set ldata = CC_MAP.get(license.type) %} + + + {% if license.type != "Publisher's own license" %} + {% include 'includes/svg/cc.svg' %} {% endif %} - {% if bibjson.editorial_review_process or bibjson.editorial_review_url %} -

  • - {% if bibjson.editorial_review_url %}{% endif %} - {% if bibjson.editorial_review_process %} - {{ bibjson.editorial_review_process|join(", ") }} - {% else %}Review process unknown + {% for license_option in ldata[1] %} + {# TODO: how do we display public domain licenses + publishers’ own? #} + {# TODO: there’s probably a better way to do this #} + {# RJ Note: I have adjusted this bit of the template to do this slightly better, but until we have journals with multiple lincenses we're not sure how weird it will look #} + {% if license_option == 'by' %}{% include 'includes/svg/by.svg' %} + Attribution {% endif %} - {% if bibjson.editorial_review_url %}{% endif %} -
  • - {% endif %} - - - {% if bibjson.plagiarism_detection %} -

    - → This journal checks for plagiarism. -

    - {% endif %} -
    -
    - - {% if bibjson.publication_time_weeks %} -
    - -
    - Expect on average {{ bibjson.publication_time_weeks }} weeks from submission to publication. -
    -
    - {% endif %} -
    - -
    -

    Best practice

    -
    - -
    - {%- set oa_start = journal.has_oa_start_date() -%} - {% if oa_start %} -

    - This journal began publishing in open access in {{ oa_start }}. - What does DOAJ define as Open Accesss? -

    - {%- endif %} - {% if bibjson.licenses %} -

    This journal uses - {% for license in bibjson.licenses %} - {%- if loop.last and bibjson.licenses|length > 1 -%} or - {%- elif not loop.first -%}, {%- endif -%} - {% if license.type == "Publisher's own license" %} their publisher’s own - {% else %} a {{ license.type }} - {%- endif -%} - {% endfor %} - license. -

    -

    - {% for license in bibjson.licenses %} - {% set ldata = CC_MAP.get(license.type) %} - - - {% if license.type != "Publisher's own license" %} - {% include 'includes/svg/cc.svg' %} - {% endif %} - {% for license_option in ldata[1] %} - {# TODO: how do we display public domain licenses + publishers’ own? #} - {# TODO: there’s probably a better way to do this #} - {# RJ Note: I have adjusted this bit of the template to do this slightly better, but until we have journals with multiple lincenses we're not sure how weird it will look #} - {% if license_option == 'by' %}{% include 'includes/svg/by.svg' %}Attribution{% endif %} - {% if license_option == 'nc' %}{% include 'includes/svg/nc.svg' %}Non-Commercial{% endif %} - {% if license_option == 'nd' %}{% include 'includes/svg/nd.svg' %}No Derivatives{% endif %} - {% if license_option == 'sa' %}{% include 'includes/svg/sa.svg' %}Share Alike{% endif %} - {% endfor %} - {% if license.type == 'CC0' %}{% include 'includes/svg/zero.svg' %}Public Domain{% endif %} - {% if loop.last %}{% else %}
    {% endif %} -
    - - {% endfor %} -

    - {% endif %} -

    - → Look up their open access statement and their license terms. -

    -
    -
    - -
    - {% include 'includes/svg/copyright.svg' %} -
    -

    - The author - {% if bibjson.author_retains_copyright %} - retains - {% else %} - does not retain - {% endif %} - unrestricted copyrights and publishing rights. -

    - {% if bibjson.copyright_url %} -

    - → Learn more about their copyright policy. -

    - {% endif %} -
    -
    - - {% if bibjson.has_preservation %} -
    - -
    -

    Articles digitally archived in:

    -
      - {% for service in bibjson.preservation_summary %} -
    • {% if service is string %}{{ service }}{% else %}{{ service|join(": ") }}{% endif %}
    • - {% endfor %} -
    - - {% if bibjson.preservation_url %} -

    - → Find out about their archiving policy. -

    + {% if license_option == 'nc' %} + {% include 'includes/svg/nc.svg' %} + Non-Commercial + {% endif %} + {% if license_option == 'nd' %} + {% include 'includes/svg/nd.svg' %} + No Derivatives + {% endif %} + {% if license_option == 'sa' %} + {% include 'includes/svg/sa.svg' %} + Share Alike + {% endif %} + {% endfor %} + {% if license.type == 'CC0' %} + {% include 'includes/svg/zero.svg' %} + Public Domain {% endif %} -
    -
    - {% endif %} + {% if loop.last %}{% else %}
    {% endif %} + - {% if bibjson.deposit_policy %} -
    - -
    -

    - Deposit policy with: -

    -
      - {% for policy in bibjson.deposit_policy %} - {% set policy_data = DEPOSIT_POLICY_MAP.get(policy) %} -
    • - {# FIXME: not a big fan of this hard-coding, presumably this could come from config somewhere #} - {% if policy == "Sherpa/Romeo" or policy == "Diadorim" or policy == "Dulcinea" %} - - {{ policy }} - - {% else %} - {{ policy }} - {% endif %} -
    • - {% endfor %} -
    -
    -
    + {% endfor %} +

    + {% endif %} +

    + → Look up their open access statement and their license terms. +

    +
    + + +
    + {% include 'includes/svg/copyright.svg' %} +
    +

    + The author + {% if bibjson.author_retains_copyright %} + retains + {% else %} + does not retain {% endif %} - - {% if bibjson.pid_scheme %} -

    - -
    -

    Permanent article identifier:

    -
      - {% for identifier in bibjson.pid_scheme %} -
    • {{ identifier }}
    • - {% endfor %} -
    -
    -
    + unrestricted copyrights and publishing rights. +

    + {% if bibjson.copyright_url %} +

    + → Learn more about their copyright policy. +

    + {% endif %} +
    +
    + + {% if bibjson.has_preservation %} +
    + +
    +

    Articles digitally archived in:

    +
      + {% for service in bibjson.preservation_summary %} +
    • {% if service is string %}{{ service }}{% else %} + {{ service|join(": ") }}{% endif %}
    • + {% endfor %} +
    + + {% if bibjson.preservation_url %} +

    + → Find out about their archiving policy. +

    {% endif %} -
    - -
    -

    Journal metadata

    - -
    - -
    - {% if bibjson.publisher_name %} -
    Publisher
    -
    - {% set source = search_query_source(terms=[{"bibjson.publisher.name.exact": [bibjson.publisher_name]}]) %} - {{bibjson.publisher_name}}{% if bibjson.publisher_country %}, {{bibjson.publisher_country_name()}}{% endif %} -
    - {% endif %} - - {% if bibjson.institution_name %} -
    Society or institution
    -
    {{bibjson.institution_name}}{% if bibjson.institution_country %}, {{ bibjson.institution_country_name() }}{% endif %}
    - {% endif %} - - {% if bibjson.language %} -
    Manuscripts accepted in
    -
    {{bibjson.language_name()|join(", ")}}
    - {% endif %} -
    -
    +
    + + {% endif %} -
    - -
    - {% for path, code in bibjson.lcc_paths_and_codes() %} - {% if loop.index0 == 0 %}
    LCC subjects Look up the Library of Congress Classification Outline
    {% endif %} -
    - {% set source = search_query_source(terms=[{"index.schema_codes_tree.exact": [code]}]) %} - - {{ path }} + {% if bibjson.deposit_policy %} +
    - {% endfor %} - - {% if bibjson.keywords %} -
    Keywords
    -
    - {% for keyword in bibjson.keywords %} - {% set source = search_query_source(query_string=keyword) %} - {{ keyword }} - {% endfor %} -
    - {% endif %} -
    -
    - -
    - - - - - - -
    -

    - Added {{journal.created_timestamp.strftime("%e %B %Y")}} - {% if journal.last_manual_update_timestamp and - dates.format(journal.last_manual_update_timestamp) != dates.DEFAULT_TIMESTAMP_VAL - %} - • Updated {{journal.last_manual_update_timestamp.strftime("%e %B %Y")}} + {% else %} + {{ policy }} + {% endif %} + + {% endfor %} + + + {% endif %} -

    -
    - -
    - {% include "includes/_hotjar.html" %} - -{% endblock %} -{% block extra_js_bottom %} + {% if bibjson.pid_scheme %} +
    + +
    +

    Permanent article identifier:

    +
      + {% for identifier in bibjson.pid_scheme %} +
    • {{ identifier }}
    • + {% endfor %} +
    +
    +
    + {% endif %} + + +
    +

    Journal metadata

    + +
    + +
    + {% if bibjson.publisher_name %} +
    Publisher
    +
    + {% set source = search_query_source(terms=[{"bibjson.publisher.name.exact": [bibjson.publisher_name]}]) %} + {{ bibjson.publisher_name }} + {% if bibjson.publisher_country %}, {{ bibjson.publisher_country_name() }}{% endif %} +
    + {% endif %} - + {% if bibjson.language %} +
    Manuscripts accepted in
    +
    {{ bibjson.language_name()|join(", ") }}
    + {% endif %} +
    +
    + +
    + +
    + {% for path, code in bibjson.lcc_paths_and_codes() %} + {% if loop.index0 == 0 %} +
    LCC subjects + + Look up the Library of Congress Classification Outline + +
    {% endif %} +
    + {% set source = search_query_source(terms=[{"index.schema_codes_tree.exact": [code]}]) %} + + {{ path }} + +
    + {% endfor %} + + {% if bibjson.keywords %} +
    Keywords
    +
    + {% for keyword in bibjson.keywords %} + {% set source = search_query_source(query_string=keyword) %} + {{ keyword }} + {% endfor %} +
    + {% endif %} +
    +
    +
    + + - {% include "_edges_common_js.html" %} - +{% endblock %} -{% endblock extra_js_bottom %} diff --git a/portality/templates/doaj/toc_articles.html b/portality/templates/doaj/toc_articles.html new file mode 100644 index 0000000000..2446a355df --- /dev/null +++ b/portality/templates/doaj/toc_articles.html @@ -0,0 +1,44 @@ +{% extends "layouts/toc_base.html" %} + +{% block toc_content %} + +
    +
    +
    +
    +
    + +{% endblock %} + +{% block extra_js_bottom %} + + + + {% include "_edges_common_js.html" %} + + +{% endblock extra_js_bottom %} diff --git a/portality/templates/layouts/toc_base.html b/portality/templates/layouts/toc_base.html new file mode 100644 index 0000000000..0c27ac504d --- /dev/null +++ b/portality/templates/layouts/toc_base.html @@ -0,0 +1,147 @@ +{% extends "layouts/public_base.html" %} + +{% block body_class %} + journal-details +{% endblock %} + +{% block page_title %}{% include "doaj/includes/_journal_meta_title.html" %}{% endblock %} +{% block meta_og_title %}{% include "doaj/includes/_journal_meta_title.html" %}{% endblock %} +{% block meta_twitter_title %}{% include "doaj/includes/_journal_meta_title.html" %}{% endblock %} +{%- block meta_description -%}{% include "doaj/includes/_journal_meta_description.html" %}{%- endblock -%} +{%- block meta_og_description -%}{% include "doaj/includes/_journal_meta_description.html" %}{%- endblock -%} +{%- block meta_twitter_description -%}{% include "doaj/includes/_journal_meta_description.html" %}{%- endblock -%} + +{% block content %} + + +
    +
    + {% if journal.last_manually_updated_since(days=30) %} + + + Updated recently + + {% endif %} +

    + + {{ bibjson.title }} + {% if bibjson.alternative_title %} + + {% endif %} + + {%- set seal = journal.has_seal() -%} + {%- if seal -%} + + {%- endif %} +

    +

    + + + {# this next bit has to be all on one line so that the spacing is correct #} + {% if bibjson.pissn %}{{bibjson.pissn}} (Print){% endif %}{% if bibjson.eissn %}{% if bibjson.pissn %} / {% endif %}{{bibjson.eissn}} (Online){% endif %} + +

    + + {% if bibjson.discontinued_date %} +

    Ceased publication on {{ bibjson.discontinued_datestamp.strftime("%d %B %Y") }}

    + {% endif %} + + {% set past = journal.get_past_continuations() %} + {% if past %} +

    Continues + {% for p in past %} + {% set bibjson = p.bibjson() %} + {% if bibjson.issns()|length > 0 %} + {% if p.is_in_doaj() %} + {{ bibjson.title }} + {% else %} + {{ bibjson.title }}, ISSN: {{ bibjson.get_preferred_issn() }} (not available in DOAJ) + {% endif %} + {% endif %} + {% if not loop.last %}; {% endif %} + {% endfor %} +

    + {% endif %} + + {% set future = journal.get_future_continuations() %} + {% if future %} +

    Continued by + {% for f in future %} + {% set bibjson = f.bibjson() %} + {% if bibjson.issns()|length > 0 %} + {% if f.is_in_doaj() %} + {{ bibjson.title }} + {% else %} + {{ bibjson.title }}, ISSN: {{ bibjson.get_preferred_issn() }} (not available in DOAJ) + {% endif %} + {% endif %} + {% if not loop.last %}; {% endif %} + {% endfor %} +

    + {% endif %} + + +
    + +
    + + +
    + {% block toc_content %} {% endblock %} +
    +
    + +
    +

    + Added {{journal.created_timestamp.strftime("%e %B %Y")}} + {% if journal.last_manual_update_timestamp and + dates.format(journal.last_manual_update_timestamp) != dates.DEFAULT_TIMESTAMP_VAL + %} + • Updated {{journal.last_manual_update_timestamp.strftime("%e %B %Y")}} + {% endif %} +

    +
    + +
    + {% include "includes/_hotjar.html" %} + +{% endblock %} diff --git a/portality/view/doaj.py b/portality/view/doaj.py index 5ac2f67f69..80ff0b2195 100644 --- a/portality/view/doaj.py +++ b/portality/view/doaj.py @@ -249,16 +249,7 @@ def autocomplete(doc_type, field_name): # http://flask.pocoo.org/docs/security/#json-security -@blueprint.route("/toc/") -@blueprint.route("/toc//") -@blueprint.route("/toc///") -def toc(identifier=None, volume=None, issue=None): - """ Table of Contents page for a journal. identifier may be the journal id or an issn """ - # If this route is changed, update JOURNAL_TOC_URL_FRAG in settings.py (partial ToC page link for journal CSV) - - journal = None - issn_ref = False - +def find_toc_journal_by_identifier(identifier): if identifier is None: abort(404) @@ -274,44 +265,40 @@ def toc(identifier=None, volume=None, issue=None): if journal is None: abort(400) - issn_ref = True # just a flag so we can check if we were requested via issn + return journal + elif len(identifier) == 32: js = models.Journal.pull(identifier) # Returns None on fail if js is None or not js.is_in_doaj(): abort(404) - journal = js - else: - abort(400) + return js + + abort(400) - # get the bibjson record that we're going to render - bibjson = journal.bibjson() - # The issn we are using to build the TOC - issn = bibjson.get_preferred_issn() +def is_issn_by_identifier(identifier): + return len(identifier) == 9 - # now redirect to the canonical E-ISSN if one is available +def find_correct_redirect_identifier(identifier, bibjson) -> str: + """ + return None if identifier is correct and no redirect is needed - if issn_ref: # the journal is referred to by an ISSN + :param identifier: + :param bibjson: + :return: + """ + if is_issn_by_identifier(identifier): # the journal is referred to by an ISSN # if there is an E-ISSN (and it's not the one in the request), redirect to it eissn = bibjson.get_one_identifier(bibjson.E_ISSN) if eissn and identifier != eissn: - return redirect(url_for('doaj.toc', identifier=eissn, volume=volume, issue=issue), 301) + return eissn # if there's no E-ISSN, but there is a P-ISSN (and it's not the one in the request), redirect to the P-ISSN if not eissn: pissn = bibjson.get_one_identifier(bibjson.P_ISSN) if pissn and identifier != pissn: - return redirect(url_for('doaj.toc', identifier=pissn, volume=volume, issue=issue), 301) - - # Add the volume and issue to query if present in path - if volume: - filters = [dao.Facetview2.make_term_filter('bibjson.journal.volume.exact', volume)] - if issue: - filters += [dao.Facetview2.make_term_filter('bibjson.journal.number.exact', issue)] - q = dao.Facetview2.make_query(filters=filters) - - return redirect(url_for('doaj.toc', identifier=issn) + '?source=' + dao.Facetview2.url_encode_query(q)) + return pissn # The journal has neither a PISSN or an EISSN. Yet somehow # issn_ref is True, the request was referring to the journal @@ -328,22 +315,52 @@ def toc(identifier=None, volume=None, issue=None): if not issn: issn = bibjson.get_one_identifier(bibjson.P_ISSN) if issn: - return redirect(url_for('doaj.toc', identifier=issn, volume=volume, issue=issue), 301) + return issn # let it continue loading if we only have the hex UUID for the journal (no ISSNs) # and the user is referring to the toc page via that ID - # get the continuations for this journal, future and past - future_journals = journal.get_future_continuations() - past_journals = journal.get_past_continuations() +@blueprint.route("/toc/") +def toc(identifier=None): + """ Table of Contents page for a journal. identifier may be the journal id or an issn """ + # If this route is changed, update JOURNAL_TOC_URL_FRAG in settings.py (partial ToC page link for journal CSV) + + journal = find_toc_journal_by_identifier(identifier) + bibjson = journal.bibjson() + real_identifier = find_correct_redirect_identifier(identifier, bibjson) + if real_identifier: + return redirect(url_for('doaj.toc', identifier=real_identifier), 301) + else: + # now render all that information + return render_template('doaj/toc.html', journal=journal, bibjson=bibjson ) + + +@blueprint.route("/toc/articles/") +@blueprint.route("/toc/articles//") +@blueprint.route("/toc/articles///") +def toc_articles(identifier=None, volume=None, issue=None): + journal = find_toc_journal_by_identifier(identifier) + bibjson = journal.bibjson() + real_identifier = find_correct_redirect_identifier(identifier, bibjson) + if real_identifier: + return redirect(url_for('doaj.toc_articles', identifier=real_identifier, + volume=volume, issue=issue), 301) + else: + + if is_issn_by_identifier(identifier) and volume: + filters = [dao.Facetview2.make_term_filter('bibjson.journal.volume.exact', volume)] + if issue: + filters += [dao.Facetview2.make_term_filter('bibjson.journal.number.exact', issue)] + q = dao.Facetview2.make_query(filters=filters) + + # The issn we are using to build the TOC + issn = bibjson.get_preferred_issn() + return redirect(url_for('doaj.toc', identifier=issn) + + '?source=' + dao.Facetview2.url_encode_query(q)) - # extract the bibjson, which is what the template is after, and whether the record is in doaj - #future = [j.bibjson() j for j in future_journals] - #past = [j.bibjson() for j in past_journals] + # now render all that information + return render_template('doaj/toc_articles.html', journal=journal, bibjson=bibjson ) - # now render all that information - return render_template('doaj/toc.html', journal=journal, bibjson=bibjson, future=future_journals, past=past_journals, - toc_issns=journal.bibjson().issns()) #~~->Article:Page~~ From 5f2c9f91009c44842e1c200fd9333d431e586605 Mon Sep 17 00:00:00 2001 From: philip Date: Wed, 2 Aug 2023 14:54:12 +0100 Subject: [PATCH 2/3] rename share toc test cases --- doajtest/unit/test_toc.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/doajtest/unit/test_toc.py b/doajtest/unit/test_toc.py index b58b20445f..dafe64ac31 100644 --- a/doajtest/unit/test_toc.py +++ b/doajtest/unit/test_toc.py @@ -5,7 +5,7 @@ from portality.util import url_for -def test_toc_uses_both_issns_when_available(app_test, url_name): +def _test_toc_uses_both_issns_when_available(app_test, url_name): j = models.Journal(**JournalFixtureFactory.make_journal_source(in_doaj=True)) pissn = j.bibjson().first_pissn eissn = j.bibjson().first_eissn @@ -20,7 +20,7 @@ def test_toc_uses_both_issns_when_available(app_test, url_name): assert eissn in response.data.decode() -def toc_correctly_uses_pissn(app_test, url_name): +def _test_toc_correctly_uses_pissn(app_test, url_name): j = models.Journal(**JournalFixtureFactory.make_journal_source(in_doaj=True)) pissn = j.bibjson().first_pissn # remove eissn @@ -35,7 +35,7 @@ def toc_correctly_uses_pissn(app_test, url_name): assert pissn in response.data.decode() -def toc_correctly_uses_eissn(app_test, url_name): +def _test_toc_correctly_uses_eissn(app_test, url_name): j = models.Journal(**JournalFixtureFactory.make_journal_source(in_doaj=True)) eissn = j.bibjson().first_eissn # remove pissn @@ -131,21 +131,21 @@ def test_02_toc_requirements(self): assert a.data['index']['date_toc_fv_month'] == a.data['index']['date'] == "1991-01-01T00:00:00Z" def test_03_toc_uses_both_issns_when_available(self): - test_toc_uses_both_issns_when_available(self.app_test, 'doaj.toc') + _test_toc_uses_both_issns_when_available(self.app_test, 'doaj.toc') def test_04_toc_correctly_uses_pissn(self): - toc_correctly_uses_pissn(self.app_test, 'doaj.toc') + _test_toc_correctly_uses_pissn(self.app_test, 'doaj.toc') def test_05_toc_correctly_uses_eissn(self): - toc_correctly_uses_eissn(self.app_test, 'doaj.toc') + _test_toc_correctly_uses_eissn(self.app_test, 'doaj.toc') class TestTOCArticles(DoajTestCase): def test_03_toc_uses_both_issns_when_available(self): - test_toc_uses_both_issns_when_available(self.app_test, 'doaj.toc_articles') + _test_toc_uses_both_issns_when_available(self.app_test, 'doaj.toc_articles') def test_04_toc_correctly_uses_pissn(self): - toc_correctly_uses_pissn(self.app_test, 'doaj.toc_articles') + _test_toc_correctly_uses_pissn(self.app_test, 'doaj.toc_articles') def test_05_toc_correctly_uses_eissn(self): - toc_correctly_uses_eissn(self.app_test, 'doaj.toc_articles') + _test_toc_correctly_uses_eissn(self.app_test, 'doaj.toc_articles') From 02954cfb0071d84d5414c62dce7fe33001bcc008 Mon Sep 17 00:00:00 2001 From: philip Date: Wed, 11 Oct 2023 10:34:05 +0100 Subject: [PATCH 3/3] fix some conflict in toc.html and toc_base.html --- portality/templates/doaj/toc.html | 5 ----- 1 file changed, 5 deletions(-) diff --git a/portality/templates/doaj/toc.html b/portality/templates/doaj/toc.html index ccf3ac1a88..df9f5a787e 100644 --- a/portality/templates/doaj/toc.html +++ b/portality/templates/doaj/toc.html @@ -17,11 +17,6 @@ "Dulcinea" : "https://www.accesoabierto.net/dulcinea/lista/REVISTA/", } %} - {% if bibjson.discontinued_date is not none and bibjson.discontinued_date | is_in_the_past %} -

    Ceased publication on {{ bibjson.discontinued_datestamp.strftime("%d %B %Y") }}

    - {% endif %} - -

    About