Skip to content

Commit

Permalink
Merge pull request #768 from gitnnolabs/fix_oaipmh_metadata
Browse files Browse the repository at this point in the history
Adiciona um propriedade no modelo de artigo para ter a origem do artigo ``source``.
  • Loading branch information
gitnnolabs authored Jun 13, 2024
2 parents 1d4fc0e + ba71389 commit d4a36c2
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 24 deletions.
32 changes: 24 additions & 8 deletions article/models.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,18 @@
import os
import sys

from datetime import datetime

from django.core.files.base import ContentFile
from django.db import models, IntegrityError
from django.db import IntegrityError, models
from django.db.utils import DataError
from django.utils.translation import gettext as _
from packtools.sps.formats import pubmed, pmc, crossref
from packtools.sps.pid_provider.xml_sps_lib import generate_finger_print
from legendarium.formatter import descriptive_format
from modelcluster.fields import ParentalKey
from modelcluster.models import ClusterableModel
from packtools.sps.formats import crossref, pmc, pubmed
from packtools.sps.pid_provider.xml_sps_lib import generate_finger_print
from wagtail.admin.panels import FieldPanel, InlinePanel, ObjectList, TabbedInterface
from wagtail.models import Orderable
from wagtail.admin.panels import FieldPanel
from wagtailautocomplete.edit_handlers import AutocompletePanel

from core.forms import CoreAdminModelForm
Expand All @@ -27,13 +26,13 @@
)
from doi.models import DOI
from doi_manager.models import CrossRefConfiguration
from institution.models import Sponsor, Publisher
from institution.models import Publisher, Sponsor
from issue.models import Issue, TocSection
from journal.models import Journal, SciELOJournal
from pid_provider.provider import PidProvider
from researcher.models import Researcher, InstitutionalAuthor
from vocabulary.models import Keyword
from researcher.models import InstitutionalAuthor, Researcher
from tracker.models import UnexpectedEvent
from vocabulary.models import Keyword


class Article(CommonControlField, ClusterableModel):
Expand Down Expand Up @@ -205,6 +204,23 @@ def data(self):

return _data

@property
def source(self):
"""
Return the format: Acta Cirúrgica Brasileira, Volume: 37, Issue: 7, Article number: e370704, Published: 10 OCT 2022
"""
leg_dict = {
"title": self.journal.title,
"pubdate": str(self.pub_date_year),
"volume": self.issue.volume,
"number": self.issue.number,
"fpage": self.first_page,
"lpage": self.last_page,
"elocation": self.elocation_id,
}

return descriptive_format(**leg_dict)

@classmethod
def get_or_create(cls, doi, pid_v2, fundings, user):
try:
Expand Down
17 changes: 1 addition & 16 deletions article/search_indexes.py
Original file line number Diff line number Diff line change
Expand Up @@ -452,22 +452,7 @@ def prepare_license(self, obj):
def prepare_sources(self, obj):
# property no article.
# Acta Cirúrgica Brasileira, Volume: 37, Issue: 7, Article number: e370704, Published: 10 OCT 2022

titles = [title.plain_text for title in obj.titles.all()]

leg_dict = {
"title": titles[0],
"pubdate": str(obj.pub_date_year),
"volume": obj.issue.volume,
"number": obj.issue.number,
"fpage": obj.first_page,
"lpage": obj.last_page,
"elocation": obj.elocation_id,
}

leg = descriptive_format(**leg_dict)

return [leg]
return obj.source

def get_model(self):
return Article
Expand Down

0 comments on commit d4a36c2

Please sign in to comment.