scieloorg / core

Other
4 stars 9 forks source link

Crear los modelos relacionados a referencias bibliográficas #360

Open robertatakenaka opened 11 months ago

robertatakenaka commented 11 months ago

Descrição da tarefa

Crear los modelos relacionados a referencias bibliográficas

En la app reference, complete el módulo models.py (https://github.com/scieloorg/core/blob/main/reference/models.py), de acuerdo con las instrucciones:

  1. Modelo Reference

Deve contener los atributos:

Crear los @classmethod create_or_update e get e usar como parámetros:

Consultar la combinación de estes 4 grupos (4 if)

Ej _ilustrativo (authors=authors y citations_ids=citationsids no van a funcionar pues es m2m):

if source and authors and article_title and year and doi:
    return Reference.objects.get(source=source, authors=authors, article_title=article_title, year=year, doi=doi)
if source and authors and article_title and year and citations_ids:
    return Reference.objects.get(source=source, authors=authors, article_title=article_title, year=year, citations_ids=citations_ids)
if source and authors and article_title and year and fpage:
    return Reference.objects.get(source=source, authors=authors, article_title=article_title, year=year, volume=volume, issue=issue, fpage=fpage, lpage=lpage)
  1. Modelo ReferenceInArticle

Deve contener los atributos:

Crear los @classmethod create_or_update e get e usar como parámetros:

  1. Modelo PubId
    • pub_id_type - CharField
    • pub_id_value - CharField

Ej.: pmid: <pub-id pub-id-type="pmid">6772889</pub-id>

<ref id="B8">
 <element-citation>
  <person-group person-group-type="author">
   <name><surname>Weissert</surname>
    <given-names>W</given-names></name>
   <name><surname>Wan</surname>
    <given-names>T</given-names></name>
   <name><surname>Livieratos</surname>
    <given-names>B</given-names></name>
   <name><surname>Katz</surname>
    <given-names>S</given-names></name>
  </person-group>
  <article-title>Effects and costs of day-care services for 
   the chronically ill: a randomized experiment</article-title>
  <source>Medical Care</source>
  <year iso-8601-date="1980">1980</year>
  <volume>18</volume>
  <fpage>567</fpage>
  <lpage>584</lpage>
  <pub-id pub-id-type="pmid">6772889</pub-id>
 </element-citation>
</ref>

Nota: futuramente vamos a usar la classe ArticleCitations para obtener los datos de las citas de los XML y completar los registros. ~https://github.com/scieloorg/packtools/blob/2b4af9f53d18db96358acdc099cd62f888c23cb8/packtools/sps/models/article_citations.py#L80C7-L80C23~

https://github.com/scieloorg/packtools/blob/master/packtools/sps/models/article_citations.py#L96

robertatakenaka commented 11 months ago

from django.db.models import Q

q = None

for item in items:
    if q is None:
        q = Q(authors__surname=item["surname"], authors__given_names=item["given_names"])
    else:
        q = q & Q(author__surname=item["surname"], author__given_names=item["given_names"])

X.objects(q, **params)