-
Notifications
You must be signed in to change notification settings - Fork 10
Adiciona validação e captura de valores inválidos em data_availability_status #1252
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
Changes from all commits
bb8ede0
8858619
1465fdd
8bf6458
094a2f6
fa09b6a
c8a43d8
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 |
|---|---|---|
| @@ -0,0 +1,60 @@ | ||
| # Generated by Django 5.2.7 on 2026-01-05 19:42 | ||
|
|
||
| from django.db import migrations, models | ||
|
|
||
|
|
||
| class Migration(migrations.Migration): | ||
|
|
||
| dependencies = [ | ||
| ("article", "0044_alter_article_accepted_dateiso_and_more"), | ||
| ] | ||
|
|
||
| operations = [ | ||
| migrations.AddField( | ||
| model_name="article", | ||
| name="invalid_data_availability_status", | ||
| field=models.CharField( | ||
| blank=True, | ||
| help_text="Armazena valores inválidos recebidos do XML", | ||
| max_length=255, | ||
| null=True, | ||
| verbose_name="Invalid data availability status from XML", | ||
| ), | ||
| ), | ||
| migrations.AlterField( | ||
| model_name="article", | ||
| name="data_availability_status", | ||
| field=models.CharField( | ||
| blank=True, | ||
| choices=[ | ||
| ( | ||
| "data-available", | ||
| "Os dados de pesquisa estão disponíveis em repositório.", | ||
| ), | ||
| ( | ||
| "data-available-upon-request", | ||
| "Os dados de pesquisa só estão disponíveis mediante solicitação.", | ||
| ), | ||
| ( | ||
| "data-in-article", | ||
| "Os dados de pesquisa estão disponíveis no corpo do documento.", | ||
| ), | ||
| ( | ||
| "data-not-available", | ||
| "Os dados de pesquisa não estão disponíveis.", | ||
| ), | ||
| ( | ||
| "uninformed", | ||
| "Uso de dados não informado; nenhum dado de pesquisa gerado ou utilizado.", | ||
| ), | ||
| ("absent", "Informação ausente no XML"), | ||
| ("not-processed", "XML não processado"), | ||
| ("invalid", "Valor inválido recebido do XML"), | ||
| ], | ||
| default="not-processed", | ||
| max_length=30, | ||
| null=True, | ||
| verbose_name="Data Availability Status", | ||
| ), | ||
| ), | ||
| ] |
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
|
|
@@ -299,32 +299,32 @@ def add_peer_review_dates(xmltree, article, errors): | |||||||
| """ | ||||||||
| try: | ||||||||
| dates = ArticleDates(xmltree=xmltree) | ||||||||
|
|
||||||||
| # Obter estatísticas completas de peer review | ||||||||
| peer_review_stats = dates.get_peer_reviewed_stats(serialize_dates=True) | ||||||||
|
|
||||||||
| # Armazenar estatísticas completas em JSON | ||||||||
| article.peer_review_stats = peer_review_stats | ||||||||
|
|
||||||||
| # Extrair datas individuais em formato ISO | ||||||||
| article.preprint_dateiso = peer_review_stats.get("preprint_date") | ||||||||
| article.received_dateiso = peer_review_stats.get("received_date") | ||||||||
| article.received_dateiso = peer_review_stats.get("received_date") | ||||||||
| article.accepted_dateiso = peer_review_stats.get("accepted_date") | ||||||||
|
|
||||||||
| # Extrair intervalos em dias | ||||||||
| article.days_preprint_to_received = peer_review_stats.get("days_from_preprint_to_received") | ||||||||
| article.days_received_to_accepted = peer_review_stats.get("days_from_received_to_accepted") | ||||||||
| article.days_accepted_to_published = peer_review_stats.get("days_from_accepted_to_published") | ||||||||
| article.days_preprint_to_published = peer_review_stats.get("days_from_preprint_to_published") | ||||||||
| article.days_receive_to_published = peer_review_stats.get("days_from_received_to_published") | ||||||||
|
|
||||||||
| # Extrair flags de estimativa | ||||||||
| article.days_preprint_to_received_estimated = peer_review_stats.get("estimated_days_from_preprint_to_received") | ||||||||
| article.days_received_to_accepted_estimated = peer_review_stats.get("estimated_days_from_received_to_accepted") | ||||||||
| article.days_accepted_to_published_estimated = peer_review_stats.get("estimated_days_from_accepted_to_published") | ||||||||
| article.days_preprint_to_published_estimated = peer_review_stats.get("estimated_days_from_preprint_to_published") | ||||||||
| article.days_receive_to_published_estimated = peer_review_stats.get("estimated_days_from_received_to_published") | ||||||||
|
|
||||||||
| except Exception as e: | ||||||||
| add_error(errors, "add_peer_review_dates", e) | ||||||||
|
|
||||||||
|
|
@@ -333,9 +333,16 @@ def add_data_availability_status(xmltree, errors, article, user): | |||||||
| """ | ||||||||
| Extrai a declaração de disponibilidade de dados do XML. | ||||||||
|
|
||||||||
| Lógica de validação: | ||||||||
| - Valor inválido: preserva em invalid_data_availability_status e marca como "invalid" | ||||||||
| - Valor válido explícito: limpa invalid_data_availability_status | ||||||||
| - Valor ausente: mantém invalid_data_availability_status inalterado (preserva histórico) | ||||||||
|
|
||||||||
| Args: | ||||||||
| xmltree: Árvore XML do artigo | ||||||||
| errors: Lista para coletar erros | ||||||||
| article: Instância do modelo Article | ||||||||
| user: Usuário responsável pela operação | ||||||||
| """ | ||||||||
| try: | ||||||||
| status = None | ||||||||
|
|
@@ -351,10 +358,23 @@ def add_data_availability_status(xmltree, errors, article, user): | |||||||
| continue | ||||||||
| items.append({"language": lang, "text": text}) | ||||||||
|
|
||||||||
| article.data_availability_status = status or choices.DATA_AVAILABILITY_STATUS_ABSENT | ||||||||
| # Valida o status extraído do XML | ||||||||
| if status is None: | ||||||||
| # Valor ausente no XML (orientação mais recente do SPS) | ||||||||
| article.data_availability_status = choices.DATA_AVAILABILITY_STATUS_ABSENT | ||||||||
| article.invalid_data_availability_status = None | ||||||||
| elif status not in choices.DATA_AVAILABILITY_STATUS_VALID_VALUES: | ||||||||
| # Valor inválido encontrado no XML | ||||||||
| article.invalid_data_availability_status = status | ||||||||
| article.data_availability_status = choices.DATA_AVAILABILITY_STATUS_INVALID | ||||||||
| else: | ||||||||
| # Valor válido explícito presente | ||||||||
| article.invalid_data_availability_status = None | ||||||||
|
||||||||
| article.invalid_data_availability_status = None | |
| # Não sobrescreve `invalid_data_availability_status` quando o status é válido ou ausente, | |
| # preservando qualquer valor inválido previamente armazenado. |
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.
OK
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.
@Rossi-Luciano acho que é melhor adicionar
article.invalid_data_availability_status = None