-
Notifications
You must be signed in to change notification settings - Fork 9
Add POST/PUT /api/v1/crossmarkpolicy endpoint para registrar CrossmarkPage #418
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
c368d62
82bfb1b
2ad5fe9
60cb8cf
5c28a56
e15a5c0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -80,3 +80,7 @@ opac/webapp/media/images/*.* | |
|
|
||
| # nodejs/gulp/etc | ||
| node_modules/ | ||
|
|
||
| # pip editable install sources | ||
| src/ | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -28,6 +28,7 @@ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| from opac_schema.v1.models import ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Article, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Collection, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| CrossmarkPage, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Issue, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Journal, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| News, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -1944,3 +1945,47 @@ def add_article( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return article.save() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # -------- CROSSMARK -------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| def add_crossmark_page(doi, is_doi_active, language, journal, url=None, text=None): | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| """ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 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 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| - ``text``: string, texto da política de atualização | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Retorna a instância de CrossmarkPage salva. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| """ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| crossmark = CrossmarkPage.objects(journal=journal, language=language).first() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if crossmark is None: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| crossmark = CrossmarkPage( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| doi=doi, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| is_doi_active=is_doi_active, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| language=language, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| journal=journal, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| else: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| crossmark.doi = doi | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| crossmark.is_doi_active = is_doi_active | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| crossmark.url = url | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| crossmark.text = text | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return crossmark.save() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+1968
to
+1986
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| crossmark = CrossmarkPage.objects(journal=journal, language=language).first() | |
| if crossmark is None: | |
| crossmark = CrossmarkPage( | |
| doi=doi, | |
| is_doi_active=is_doi_active, | |
| language=language, | |
| journal=journal, | |
| ) | |
| else: | |
| crossmark.doi = doi | |
| crossmark.is_doi_active = is_doi_active | |
| crossmark.url = url | |
| crossmark.text = text | |
| return crossmark.save() | |
| crossmark = CrossmarkPage.objects(journal=journal, language=language).modify( | |
| upsert=True, | |
| new=True, | |
| set__doi=doi, | |
| set__is_doi_active=is_doi_active, | |
| set__url=url, | |
| set__text=text, | |
| set_on_insert__journal=journal, | |
| set_on_insert__language=language, | |
| ) | |
| return crossmark |
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -2220,6 +2220,70 @@ 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", | ||||||
| "url": "https://example.com/crossmark", | ||||||
| "text": "Crossmark policy text" | ||||||
| } | ||||||
|
|
||||||
| O campo ``journal_id`` pode ser um eISSN, pISSN ou scielo_issn do periódico. | ||||||
| """ | ||||||
| payload = request.get_json() | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @copilot payload tem que ter url e text
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||||||
| payload = request.get_json() | |
| payload = request.get_json(silent=True) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
/api/v1/crossmarkpolicyendpoint is decorated with@helper.token_required(token must be provided as atokenquery param). These tests callurl_for("restapi.crossmarkpolicy")without supplying a token, so they will receive 401 responses from the decorator. Update the test requests to include a valid token (e.g.,url_for(..., token=<jwt>)orquery_string={"token": ...}), consistent with how the endpoint is authenticated.