Skip to content
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

Disponibiliza o campo doi_prefix na API Journal #830

Merged
merged 11 commits into from
Oct 1, 2024
13 changes: 6 additions & 7 deletions article/api/v1/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,9 @@ class ArticleViewSet(viewsets.ModelViewSet):
http_method_names = ["get"]
queryset = models.Article.objects.all()

# def get_queryset(self):
# """
# This view should return a list of all published Education.
# """
# # user = self.request.user

# return models.Article.objects.all()
def get_queryset(self):
queryset = models.Article.objects.all()
doi_prefix = self.request.query_params.get('doi_prefix', None)
if doi_prefix is not None:
queryset = queryset.filter(journal__doi_prefix=doi_prefix)
return queryset
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@samuelveigarangel qual é o propósito?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Filtar os artigos pelo o prefixo do doi. Não há necessidade?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@samuelveigarangel ok, mas não acho que há este caso de uso... mas se houver a consulta é diretamente no Article, não seria necessário o filter ser pelo journal, está esquisito. Que tal:

def get_queryset(self):
        doi_prefix = self.request.query_params.get('doi_prefix', None)
        if doi_prefix is not None:
            return models.Article.objects.filter(doi__value__startswith=doi_prefix)
        return models.Article.objects.all()

O tamanho 50 para o prefixo está muito grande. O tamanho total indicado para o DOI está como 100.
Consulte: https://www.crossref.org/documentation/member-setup/constructing-your-dois/

1 change: 1 addition & 0 deletions journal/api/v1/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,4 +121,5 @@ class Meta:
"subject_descriptor",
"subject",
"text_language",
"doi_prefix",
]
18 changes: 18 additions & 0 deletions journal/migrations/0027_journal_doi_prefix.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 5.0.3 on 2024-08-01 06:04

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
("journal", "0026_editorialpolicy_opensciencecompliance"),
]

operations = [
migrations.AddField(
model_name="journal",
name="doi_prefix",
field=models.CharField(blank=True, max_length=50, null=True),
),
]
1 change: 1 addition & 0 deletions journal/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -570,6 +570,7 @@ class Journal(CommonControlField, ClusterableModel):
blank=True,
verbose_name=_("DigitalPreservationAgency"),
)
doi_prefix = models.CharField(max_length=50, blank=True, null=True)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@samuelveigarangel
O tamanho 50 para o prefixo está muito grande. O tamanho total indicado para o DOI está como 100.
Consulte: https://www.crossref.org/documentation/member-setup/constructing-your-dois/

valid = models.BooleanField(default=False, null=True, blank=True)

autocomplete_search_field = "title"
Expand Down
Loading