From c368d62e51733c0358c92a999cdb6083d67398da Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 6 Mar 2026 19:14:06 +0000 Subject: [PATCH 1/6] Initial plan From 82bfb1ba328906ef85dbdc2f139cc6e189f7dad5 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 6 Mar 2026 19:26:57 +0000 Subject: [PATCH 2/6] Add CrossmarkPage model and /api/v1/crossmarkpolicy endpoint - Add CrossmarkPage MongoEngine Document model in crossmark_models.py - Add add_crossmark_page and get_crossmark_page_by_doi controller functions - Add POST/PUT /api/v1/crossmarkpolicy REST API endpoint - Add RestAPICrossmarkPageTestCase tests for the new endpoint Co-authored-by: robertatakenaka <505143+robertatakenaka@users.noreply.github.com> --- opac/tests/test_restapi.py | 153 +++++++++++++++++++++++++++++++- opac/webapp/controllers.py | 39 ++++++++ opac/webapp/crossmark_models.py | 37 ++++++++ opac/webapp/main/views.py | 52 +++++++++++ src/opac-schema | 1 + src/packtools | 1 + src/scieloh5m5 | 1 + 7 files changed, 283 insertions(+), 1 deletion(-) create mode 100644 opac/webapp/crossmark_models.py create mode 160000 src/opac-schema create mode 160000 src/packtools create mode 160000 src/scieloh5m5 diff --git a/opac/tests/test_restapi.py b/opac/tests/test_restapi.py index db1cd0d97..a13bd27ee 100644 --- a/opac/tests/test_restapi.py +++ b/opac/tests/test_restapi.py @@ -7,6 +7,7 @@ from opac_schema.v1 import models from .base import BaseTestCase +from webapp.crossmark_models import CrossmarkPage FIXTURES_PATH = os.path.join(os.path.dirname(os.path.abspath(__file__)), "fixtures") @@ -563,4 +564,154 @@ def test_sync_issue_not_found(self, mock_get_issue_by_iid): data = resp.get_json() self.assertEqual(resp.status_code, 404) self.assertEqual(data.get("failed"), True) - self.assertEqual(data.get("error"), "issue not found") \ No newline at end of file + self.assertEqual(data.get("error"), "issue not found") + +class RestAPICrossmarkPageTestCase(BaseTestCase): + def load_json_fixture(self, filename): + with open(os.path.join(FIXTURES_PATH, filename)) as f: + return json.load(f) + + def setUp(self): + self.journal_dict = self.load_json_fixture("journal_payload.json") + self.crossmark_payload = { + "doi": "10.1234/example.doi", + "is_doi_active": True, + "language": "pt", + "journal_id": "1678-4464", + } + + def _create_journal(self): + with self.client as client: + client.post( + url_for("restapi.journal"), + data=json.dumps(self.journal_dict), + follow_redirects=True, + content_type="application/json", + ) + + def test_add_crossmarkpolicy(self): + with current_app.app_context(): + self._create_journal() + with self.client as client: + response = client.post( + url_for("restapi.crossmarkpolicy"), + data=json.dumps(self.crossmark_payload), + follow_redirects=True, + content_type="application/json", + ) + self.assertEqual(response.status_code, 200) + data = response.get_json() + self.assertFalse(data["failed"]) + self.assertEqual(data["doi"], self.crossmark_payload["doi"]) + crossmark = CrossmarkPage.objects(doi=self.crossmark_payload["doi"]).first() + self.assertIsNotNone(crossmark) + self.assertEqual(crossmark.doi, self.crossmark_payload["doi"]) + self.assertTrue(crossmark.is_doi_active) + self.assertEqual(crossmark.language, "pt") + + def test_add_crossmarkpolicy_missing_doi(self): + with current_app.app_context(): + self._create_journal() + payload = dict(self.crossmark_payload) + del payload["doi"] + with self.client as client: + response = client.post( + url_for("restapi.crossmarkpolicy"), + data=json.dumps(payload), + follow_redirects=True, + content_type="application/json", + ) + self.assertEqual(response.status_code, 400) + data = response.get_json() + self.assertTrue(data["failed"]) + self.assertIn("doi", data["error"]) + + def test_add_crossmarkpolicy_missing_language(self): + with current_app.app_context(): + self._create_journal() + payload = dict(self.crossmark_payload) + del payload["language"] + with self.client as client: + response = client.post( + url_for("restapi.crossmarkpolicy"), + data=json.dumps(payload), + follow_redirects=True, + content_type="application/json", + ) + self.assertEqual(response.status_code, 400) + data = response.get_json() + self.assertTrue(data["failed"]) + self.assertIn("language", data["error"]) + + def test_add_crossmarkpolicy_missing_journal_id(self): + with current_app.app_context(): + payload = dict(self.crossmark_payload) + del payload["journal_id"] + with self.client as client: + response = client.post( + url_for("restapi.crossmarkpolicy"), + data=json.dumps(payload), + follow_redirects=True, + content_type="application/json", + ) + self.assertEqual(response.status_code, 400) + data = response.get_json() + self.assertTrue(data["failed"]) + self.assertIn("journal_id", data["error"]) + + def test_add_crossmarkpolicy_journal_not_found(self): + with current_app.app_context(): + payload = dict(self.crossmark_payload) + payload["journal_id"] = "9999-9999" + with self.client as client: + response = client.post( + url_for("restapi.crossmarkpolicy"), + data=json.dumps(payload), + follow_redirects=True, + content_type="application/json", + ) + self.assertEqual(response.status_code, 404) + data = response.get_json() + self.assertTrue(data["failed"]) + self.assertEqual(data["error"], "journal not found") + + def test_update_crossmarkpolicy(self): + with current_app.app_context(): + self._create_journal() + with self.client as client: + client.post( + url_for("restapi.crossmarkpolicy"), + data=json.dumps(self.crossmark_payload), + follow_redirects=True, + content_type="application/json", + ) + updated_payload = dict(self.crossmark_payload) + updated_payload["is_doi_active"] = False + updated_payload["language"] = "en" + with self.client as client: + response = client.put( + url_for("restapi.crossmarkpolicy"), + data=json.dumps(updated_payload), + follow_redirects=True, + content_type="application/json", + ) + self.assertEqual(response.status_code, 200) + data = response.get_json() + self.assertFalse(data["failed"]) + crossmark = CrossmarkPage.objects(doi=self.crossmark_payload["doi"]).first() + self.assertFalse(crossmark.is_doi_active) + self.assertEqual(crossmark.language, "en") + self.assertEqual(CrossmarkPage.objects.count(), 1) + + def test_add_crossmarkpolicy_missing_payload(self): + with current_app.app_context(): + with self.client as client: + response = client.post( + url_for("restapi.crossmarkpolicy"), + data=None, + follow_redirects=True, + content_type="application/json", + ) + self.assertEqual(response.status_code, 400) + data = response.get_json() + self.assertTrue(data["failed"]) diff --git a/opac/webapp/controllers.py b/opac/webapp/controllers.py index a80d5d8d8..05c0d4dd5 100644 --- a/opac/webapp/controllers.py +++ b/opac/webapp/controllers.py @@ -36,6 +36,7 @@ Sponsor, LastIssue, ) +from .crossmark_models import CrossmarkPage from scieloh5m5 import h5m5 from slugify import slugify from webapp import dbsql @@ -1944,3 +1945,41 @@ def add_article( ) return article.save() + + +# -------- CROSSMARK -------- + + +def add_crossmark_page(doi, is_doi_active, language, journal): + """ + Cria ou atualiza um registro de CrossmarkPage. + + - ``doi``: string, DOI do documento + - ``is_doi_active``: bool, indica se o DOI está ativo + - ``language``: string, código do idioma (máx. 5 caracteres) + - ``journal``: instância de Journal + + Retorna a instância de CrossmarkPage salva. + """ + crossmark = CrossmarkPage.objects(doi=doi).first() + + if crossmark is None: + crossmark = CrossmarkPage( + doi=doi, + is_doi_active=is_doi_active, + language=language, + journal=journal, + ) + else: + crossmark.is_doi_active = is_doi_active + crossmark.language = language + crossmark.journal = journal + + return crossmark.save() + + +def get_crossmark_page_by_doi(doi): + """ + Retorna um CrossmarkPage pelo seu DOI, ou None se não existir. + """ + return CrossmarkPage.objects(doi=doi).first() diff --git a/opac/webapp/crossmark_models.py b/opac/webapp/crossmark_models.py new file mode 100644 index 000000000..0e2ebf416 --- /dev/null +++ b/opac/webapp/crossmark_models.py @@ -0,0 +1,37 @@ +# coding: utf-8 + +""" +Modelos MongoEngine para dados de política de atualização (Crossmark) dos periódicos. +""" + +from datetime import datetime, timezone + +from mongoengine import ( + BooleanField, + CASCADE, + DateTimeField, + Document, + ReferenceField, + StringField, +) +from opac_schema.v1.models import Journal + + +class CrossmarkPage(Document): + doi = StringField(required=True, unique=True) + is_doi_active = BooleanField(required=True, default=True) + language = StringField(max_length=5, required=True) + journal = ReferenceField(Journal, reverse_delete_rule=CASCADE, required=True) + created_at = DateTimeField() + updated_at = DateTimeField() + + meta = { + "collection": "crossmark_page", + "indexes": ["doi", "journal"], + } + + def save(self, *args, **kwargs): + if not self.created_at: + self.created_at = datetime.now(timezone.utc) + self.updated_at = datetime.now(timezone.utc) + return super(CrossmarkPage, self).save(*args, **kwargs) diff --git a/opac/webapp/main/views.py b/opac/webapp/main/views.py index b7ad99729..bd08a4942 100644 --- a/opac/webapp/main/views.py +++ b/opac/webapp/main/views.py @@ -2220,6 +2220,58 @@ def journal_last_issues(*args): return list(controllers.journal_last_issues() or []) +@restapi.route("/crossmarkpolicy", methods=["POST", "PUT"]) +@helper.token_required +def crossmarkpolicy(*args): + """ + Endpoint para criar ou atualizar a política de atualização (CrossmarkPage) de um periódico. + + Payload de exemplo: + { + "doi": "10.1234/example.doi", + "is_doi_active": true, + "language": "pt", + "journal_id": "1678-4464" + } + + O campo ``journal_id`` pode ser um eISSN, pISSN ou scielo_issn do periódico. + """ + payload = request.get_json() + + if not payload: + return jsonify({"failed": True, "error": "missing payload"}), 400 + + doi = payload.get("doi") + if not doi: + return jsonify({"failed": True, "error": "missing field: doi"}), 400 + + language = payload.get("language") + if not language: + return jsonify({"failed": True, "error": "missing field: language"}), 400 + + journal_id = payload.get("journal_id") + if not journal_id: + return jsonify({"failed": True, "error": "missing field: journal_id"}), 400 + + journal = controllers.get_journal_by_issn(issn=journal_id) + if not journal: + return jsonify({"failed": True, "error": "journal not found"}), 404 + + is_doi_active = payload.get("is_doi_active", True) + + try: + crossmark = controllers.add_crossmark_page( + doi=doi, + is_doi_active=is_doi_active, + language=language, + journal=journal, + ) + except Exception as ex: + return jsonify({"failed": True, "error": str(ex)}), 500 + else: + return jsonify({"failed": False, "doi": crossmark.doi}), 200 + + def remover_tags_html(texto): soup = BeautifulSoup(texto, 'html.parser') return soup.get_text() diff --git a/src/opac-schema b/src/opac-schema new file mode 160000 index 000000000..2bb30ecb4 --- /dev/null +++ b/src/opac-schema @@ -0,0 +1 @@ +Subproject commit 2bb30ecb425eaa282be0492f9eaacd64fd6b3909 diff --git a/src/packtools b/src/packtools new file mode 160000 index 000000000..e3d3641af --- /dev/null +++ b/src/packtools @@ -0,0 +1 @@ +Subproject commit e3d3641af12e6cc47435969a1b94e502e6ebfc2a diff --git a/src/scieloh5m5 b/src/scieloh5m5 new file mode 160000 index 000000000..ad942d31e --- /dev/null +++ b/src/scieloh5m5 @@ -0,0 +1 @@ +Subproject commit ad942d31e19148cb6a84900b90b44e76c848401b From 2ad5fe9761d905688b9ecd78d79d453fa69844cb Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 6 Mar 2026 19:27:30 +0000 Subject: [PATCH 3/6] Remove accidental submodule commits and add src/ to .gitignore Co-authored-by: robertatakenaka <505143+robertatakenaka@users.noreply.github.com> --- .gitignore | 4 ++++ src/opac-schema | 1 - src/packtools | 1 - src/scieloh5m5 | 1 - 4 files changed, 4 insertions(+), 3 deletions(-) delete mode 160000 src/opac-schema delete mode 160000 src/packtools delete mode 160000 src/scieloh5m5 diff --git a/.gitignore b/.gitignore index d230d7d50..15d7272e8 100644 --- a/.gitignore +++ b/.gitignore @@ -80,3 +80,7 @@ opac/webapp/media/images/*.* # nodejs/gulp/etc node_modules/ + +# pip editable install sources +src/ + diff --git a/src/opac-schema b/src/opac-schema deleted file mode 160000 index 2bb30ecb4..000000000 --- a/src/opac-schema +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 2bb30ecb425eaa282be0492f9eaacd64fd6b3909 diff --git a/src/packtools b/src/packtools deleted file mode 160000 index e3d3641af..000000000 --- a/src/packtools +++ /dev/null @@ -1 +0,0 @@ -Subproject commit e3d3641af12e6cc47435969a1b94e502e6ebfc2a diff --git a/src/scieloh5m5 b/src/scieloh5m5 deleted file mode 160000 index ad942d31e..000000000 --- a/src/scieloh5m5 +++ /dev/null @@ -1 +0,0 @@ -Subproject commit ad942d31e19148cb6a84900b90b44e76c848401b From 60cb8cf96993e80bbd3c1a3f5218f3f6daa92771 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 7 Mar 2026 15:06:16 +0000 Subject: [PATCH 4/6] Use CrossmarkPage from opac_schema.v1.models, add url/text support - Remove local crossmark_models.py: CrossmarkPage now imported from opac_schema.v1.models - Update requirements.txt to pin opac_schema to commit ebef33fb (which introduces CrossmarkPage) - Update controllers.py to import CrossmarkPage from opac_schema.v1.models - Add url and text field support in add_crossmark_page controller and endpoint - Update test import to use opac_schema.v1.models.CrossmarkPage Co-authored-by: robertatakenaka <505143+robertatakenaka@users.noreply.github.com> --- opac/tests/test_restapi.py | 2 +- opac/webapp/controllers.py | 9 ++++++-- opac/webapp/crossmark_models.py | 37 --------------------------------- opac/webapp/main/views.py | 8 ++++++- requirements.txt | 2 +- 5 files changed, 16 insertions(+), 42 deletions(-) delete mode 100644 opac/webapp/crossmark_models.py diff --git a/opac/tests/test_restapi.py b/opac/tests/test_restapi.py index a13bd27ee..1549a2732 100644 --- a/opac/tests/test_restapi.py +++ b/opac/tests/test_restapi.py @@ -5,9 +5,9 @@ from flask import current_app, url_for from flask_babelex import gettext as _ from opac_schema.v1 import models +from opac_schema.v1.models import CrossmarkPage from .base import BaseTestCase -from webapp.crossmark_models import CrossmarkPage FIXTURES_PATH = os.path.join(os.path.dirname(os.path.abspath(__file__)), "fixtures") diff --git a/opac/webapp/controllers.py b/opac/webapp/controllers.py index 05c0d4dd5..e9430b5bd 100644 --- a/opac/webapp/controllers.py +++ b/opac/webapp/controllers.py @@ -28,6 +28,7 @@ from opac_schema.v1.models import ( Article, Collection, + CrossmarkPage, Issue, Journal, News, @@ -36,7 +37,6 @@ Sponsor, LastIssue, ) -from .crossmark_models import CrossmarkPage from scieloh5m5 import h5m5 from slugify import slugify from webapp import dbsql @@ -1950,7 +1950,7 @@ def add_article( # -------- CROSSMARK -------- -def add_crossmark_page(doi, is_doi_active, language, journal): +def add_crossmark_page(doi, is_doi_active, language, journal, url=None, text=None): """ Cria ou atualiza um registro de CrossmarkPage. @@ -1958,6 +1958,8 @@ def add_crossmark_page(doi, is_doi_active, language, journal): - ``is_doi_active``: bool, indica se o DOI está ativo - ``language``: string, código do idioma (máx. 5 caracteres) - ``journal``: instância de Journal + - ``url``: string, URL da política de atualização (opcional) + - ``text``: string, texto da política de atualização (opcional) Retorna a instância de CrossmarkPage salva. """ @@ -1975,6 +1977,9 @@ def add_crossmark_page(doi, is_doi_active, language, journal): crossmark.language = language crossmark.journal = journal + crossmark.url = url + crossmark.text = text + return crossmark.save() diff --git a/opac/webapp/crossmark_models.py b/opac/webapp/crossmark_models.py deleted file mode 100644 index 0e2ebf416..000000000 --- a/opac/webapp/crossmark_models.py +++ /dev/null @@ -1,37 +0,0 @@ -# coding: utf-8 - -""" -Modelos MongoEngine para dados de política de atualização (Crossmark) dos periódicos. -""" - -from datetime import datetime, timezone - -from mongoengine import ( - BooleanField, - CASCADE, - DateTimeField, - Document, - ReferenceField, - StringField, -) -from opac_schema.v1.models import Journal - - -class CrossmarkPage(Document): - doi = StringField(required=True, unique=True) - is_doi_active = BooleanField(required=True, default=True) - language = StringField(max_length=5, required=True) - journal = ReferenceField(Journal, reverse_delete_rule=CASCADE, required=True) - created_at = DateTimeField() - updated_at = DateTimeField() - - meta = { - "collection": "crossmark_page", - "indexes": ["doi", "journal"], - } - - def save(self, *args, **kwargs): - if not self.created_at: - self.created_at = datetime.now(timezone.utc) - self.updated_at = datetime.now(timezone.utc) - return super(CrossmarkPage, self).save(*args, **kwargs) diff --git a/opac/webapp/main/views.py b/opac/webapp/main/views.py index bd08a4942..271d9cfd8 100644 --- a/opac/webapp/main/views.py +++ b/opac/webapp/main/views.py @@ -2231,7 +2231,9 @@ def crossmarkpolicy(*args): "doi": "10.1234/example.doi", "is_doi_active": true, "language": "pt", - "journal_id": "1678-4464" + "journal_id": "1678-4464", + "url": "https://example.com/crossmark", + "text": "Crossmark policy text" } O campo ``journal_id`` pode ser um eISSN, pISSN ou scielo_issn do periódico. @@ -2258,6 +2260,8 @@ def crossmarkpolicy(*args): return jsonify({"failed": True, "error": "journal not found"}), 404 is_doi_active = payload.get("is_doi_active", True) + url = payload.get("url") + text = payload.get("text") try: crossmark = controllers.add_crossmark_page( @@ -2265,6 +2269,8 @@ def crossmarkpolicy(*args): is_doi_active=is_doi_active, language=language, journal=journal, + url=url, + text=text, ) except Exception as ex: return jsonify({"failed": True, "error": str(ex)}), 500 diff --git a/requirements.txt b/requirements.txt index ab7703529..106510af8 100644 --- a/requirements.txt +++ b/requirements.txt @@ -94,6 +94,6 @@ zope.interface==5.5.2 tox==4.3.5 PyJWT==2.8.0 tenacity==8.2.3 --e git+https://git@github.com/scieloorg/opac_schema@v2.9.0#egg=Opac_Schema +-e git+https://git@github.com/scieloorg/opac_schema@ebef33fb368e93c223b1cad31959809d6f3d5018#egg=Opac_Schema -e git+https://git@github.com/scieloorg/packtools@4.12.4#egg=packtools -e git+https://github.com/scieloorg/scieloh5m5.git@1.9.5#egg=scieloh5m5 From 5c28a5686a4f647c8a1203d984a09ec59b1a89e7 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 7 Mar 2026 15:10:12 +0000 Subject: [PATCH 5/6] Change crossmark lookup to journal+language, require url/text in payload - controllers.py: change CrossmarkPage.objects(doi=doi) to CrossmarkPage.objects(journal=journal, language=language); update doi on existing records - views.py: make url and text required fields in POST/PUT payload - test_restapi.py: add url/text to base payload; add missing-url and missing-text test cases; fix update test to keep same language (since lookup key is now journal+language) Co-authored-by: robertatakenaka <505143+robertatakenaka@users.noreply.github.com> --- opac/tests/test_restapi.py | 42 +++++++++++++++++++++++++++++++++++--- opac/webapp/controllers.py | 11 +++++----- opac/webapp/main/views.py | 6 ++++++ 3 files changed, 51 insertions(+), 8 deletions(-) diff --git a/opac/tests/test_restapi.py b/opac/tests/test_restapi.py index 1549a2732..645f3846f 100644 --- a/opac/tests/test_restapi.py +++ b/opac/tests/test_restapi.py @@ -578,6 +578,8 @@ def setUp(self): "is_doi_active": True, "language": "pt", "journal_id": "1678-4464", + "url": "https://example.com/crossmark", + "text": "Crossmark policy text", } def _create_journal(self): @@ -675,6 +677,40 @@ def test_add_crossmarkpolicy_journal_not_found(self): self.assertTrue(data["failed"]) self.assertEqual(data["error"], "journal not found") + def test_add_crossmarkpolicy_missing_url(self): + with current_app.app_context(): + self._create_journal() + payload = dict(self.crossmark_payload) + del payload["url"] + with self.client as client: + response = client.post( + url_for("restapi.crossmarkpolicy"), + data=json.dumps(payload), + follow_redirects=True, + content_type="application/json", + ) + self.assertEqual(response.status_code, 400) + data = response.get_json() + self.assertTrue(data["failed"]) + self.assertIn("url", data["error"]) + + def test_add_crossmarkpolicy_missing_text(self): + with current_app.app_context(): + self._create_journal() + payload = dict(self.crossmark_payload) + del payload["text"] + with self.client as client: + response = client.post( + url_for("restapi.crossmarkpolicy"), + data=json.dumps(payload), + follow_redirects=True, + content_type="application/json", + ) + self.assertEqual(response.status_code, 400) + data = response.get_json() + self.assertTrue(data["failed"]) + self.assertIn("text", data["error"]) + def test_update_crossmarkpolicy(self): with current_app.app_context(): self._create_journal() @@ -686,8 +722,8 @@ def test_update_crossmarkpolicy(self): content_type="application/json", ) updated_payload = dict(self.crossmark_payload) + updated_payload["doi"] = "10.1234/updated.doi" updated_payload["is_doi_active"] = False - updated_payload["language"] = "en" with self.client as client: response = client.put( url_for("restapi.crossmarkpolicy"), @@ -698,9 +734,9 @@ def test_update_crossmarkpolicy(self): self.assertEqual(response.status_code, 200) data = response.get_json() self.assertFalse(data["failed"]) - crossmark = CrossmarkPage.objects(doi=self.crossmark_payload["doi"]).first() + crossmark = CrossmarkPage.objects(doi=updated_payload["doi"]).first() self.assertFalse(crossmark.is_doi_active) - self.assertEqual(crossmark.language, "en") + self.assertEqual(crossmark.language, "pt") self.assertEqual(CrossmarkPage.objects.count(), 1) def test_add_crossmarkpolicy_missing_payload(self): diff --git a/opac/webapp/controllers.py b/opac/webapp/controllers.py index e9430b5bd..4841ad02a 100644 --- a/opac/webapp/controllers.py +++ b/opac/webapp/controllers.py @@ -1954,16 +1954,18 @@ def add_crossmark_page(doi, is_doi_active, language, journal, url=None, text=Non """ Cria ou atualiza um registro de CrossmarkPage. + O registro é identificado pela combinação de ``journal`` e ``language``. + - ``doi``: string, DOI do documento - ``is_doi_active``: bool, indica se o DOI está ativo - ``language``: string, código do idioma (máx. 5 caracteres) - ``journal``: instância de Journal - - ``url``: string, URL da política de atualização (opcional) - - ``text``: string, texto da política de atualização (opcional) + - ``url``: string, URL da política de atualização + - ``text``: string, texto da política de atualização Retorna a instância de CrossmarkPage salva. """ - crossmark = CrossmarkPage.objects(doi=doi).first() + crossmark = CrossmarkPage.objects(journal=journal, language=language).first() if crossmark is None: crossmark = CrossmarkPage( @@ -1973,9 +1975,8 @@ def add_crossmark_page(doi, is_doi_active, language, journal, url=None, text=Non journal=journal, ) else: + crossmark.doi = doi crossmark.is_doi_active = is_doi_active - crossmark.language = language - crossmark.journal = journal crossmark.url = url crossmark.text = text diff --git a/opac/webapp/main/views.py b/opac/webapp/main/views.py index 271d9cfd8..bb95446d3 100644 --- a/opac/webapp/main/views.py +++ b/opac/webapp/main/views.py @@ -2260,8 +2260,14 @@ def crossmarkpolicy(*args): return jsonify({"failed": True, "error": "journal not found"}), 404 is_doi_active = payload.get("is_doi_active", True) + url = payload.get("url") + if not url: + return jsonify({"failed": True, "error": "missing field: url"}), 400 + text = payload.get("text") + if not text: + return jsonify({"failed": True, "error": "missing field: text"}), 400 try: crossmark = controllers.add_crossmark_page( From e15a5c08ed21f7bf6adb72adcec4e3f1d6836852 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 7 Mar 2026 20:56:52 +0000 Subject: [PATCH 6/6] Pin opac-schema to 2.10.0 release instead of git commit hash Co-authored-by: robertatakenaka <505143+robertatakenaka@users.noreply.github.com> --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index 106510af8..cf45533b7 100644 --- a/requirements.txt +++ b/requirements.txt @@ -94,6 +94,6 @@ zope.interface==5.5.2 tox==4.3.5 PyJWT==2.8.0 tenacity==8.2.3 --e git+https://git@github.com/scieloorg/opac_schema@ebef33fb368e93c223b1cad31959809d6f3d5018#egg=Opac_Schema +opac-schema==2.10.0 -e git+https://git@github.com/scieloorg/packtools@4.12.4#egg=packtools -e git+https://github.com/scieloorg/scieloh5m5.git@1.9.5#egg=scieloh5m5