Skip to content

Conversation

@Rossi-Luciano
Copy link
Collaborator

@Rossi-Luciano Rossi-Luciano commented Dec 7, 2025

O que esse PR faz?

Modifica template OAI-PMH article_compile.txt para geração de metadados nos formatos AOI_DC e MODS

Problemas corrigidos:

  1. dc:publisher usava caminho inválido object.publisher (Article não tem este campo)
  2. dc:source usava campo inexistente object.source
  3. dc:rights usava object.license.all() (license é ForeignKey, não ManyToMany)
  4. dc:description usava {{ abs }} ao invés de {{ abs.plain_text }}
  5. Elemento dc:language não seguia qualificador ISO padrão
  6. Estrutura Dublin Core não seguia ordem e qualificadores recomendados

Implementações:

  • dc:publisher extraído de journal.publisher_history.first() com suporte a institution/organization
  • dc:source gerado dinamicamente como citação bibliográfica (título, volume, número, páginas, ano)
  • dc:rights corrigido para ForeignKey + license_statements (ManyToMany)
  • dc:date expandido com issued/accessioned/available
  • dc:identifier estruturado com qualificadores none/doi/uri
  • dc:contributor/author ao invés de dc:creator/none
  • dc:language/iso ao invés de dc:language/none
  • dc:description/abstract ao invés de dc:description/none

Onde a revisão poderia começar?

Arquivo: article/templates/search/indexes/article/article_compile.txt


Algum cenário de contexto que queira dar?

Mantidos os índices Solr originais. A geração de metadados OAI_DC e MODS ocorre via template article_compile.txt, independente da indexação. Os métodos prepare_mods_* para indexação de campos MODS já foram desenvolvidos e podem ser integrados quando necessário.

Screenshots

índice enxuto
image

formatos disponíveis
image

exemplo padrão MODS
image

exemplo padrão OAI_DC
image

Exemplo de XML gerado

XML original

Formato OAI_DC gerado

<oai_dc:dc xmlns:doc="http://www.lyncode.com/xoai" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:oai_dc="http://www.openarchives.org/OAI/2.0/oai_dc/" xsi:schemaLocation="http://www.openarchives.org/OAI/2.0/oai_dc/ http://www.openarchives.org/OAI/2.0/oai_dc.xsd">
   <dc:title>Trends and gaps in microplastics research in Tropical freshwater ecosystems</dc:title>
   <dc:creator orcid="0000-0002-6857-1198">MARINA F. MOREIRA</dc:creator>
   <dc:creator orcid="0000-0002-0108-8572">CECÍLIA G. LEAL</dc:creator>
   <dc:creator orcid="0000-0002-7938-1517">PAULO S. POMPEU</dc:creator>
   <dc:subject>plastic pollution</dc:subject>
   <dc:subject>Aquatic environment</dc:subject>
   <dc:subject>bibliometric review</dc:subject>
   <dc:subject>Tropical ecosystems</dc:subject>
   <dc:description>Abstract Although the contamination of microplastics is a very recent topic, knowledge increased rapidly, especially in the last decade. Despite this, freshwater ecosystems have received less attention than marine ones, particularly in the tropics. Considering the particularities of Tropical freshwater ecosystems that can be important in the microplastics dynamic, such as the high rate of untreated water, the flooding dynamics and high number of reservoirs, our review aims to present the state of the research of microplastic contamination in Tropical freshwater ecosystems, emphasizing the knowledge advances and existing gaps. We compared studies in different countries, ecosystems and type of samples, and identified gaps and needs for futures research. Although research and the complexity of studies have increased over the years, Tropical freshwater ecosystems are still understudied. We emphasized the need for more studies in African countries and Tropical Australia, as well as in reservoirs across all Tropical regions. It is also crucial to evaluate contamination related to flooding dynamics and in aquatic invertebrates. Advancements in research on this topic are essential to provide a clear picture of the real problem in the tropics, leading to the possibility of better mitigation and conservation actions in the future.</dc:description>
   <dc:date>2025-11-17</dc:date>
   <dc:date>2025-11-10T11:02:57.696802+00:00</dc:date>
   <dc:date>2025-12-05T14:44:59.593840+00:00</dc:date>
   <dc:type>research-article</dc:type>
   <dc:identifier>S0001-37652025001201003</dc:identifier>
   <dc:identifier>tWn7Y4H7bcmmqjm4Qb5zLrL</dc:identifier>
   <dc:identifier>10.1590/0001-3765202520241229</dc:identifier>
   <dc:identifier>http://www.scielosp.org/scielo.php?script=sci_arttext&amp;pid=S0001-37652025001201003&amp;tlng=en</dc:identifier>
   <dc:language>en</dc:language>
   <dc:rights>CC BY 4.0</dc:rights>
   <dc:format>text/html</dc:format>
   <dc:publisher>Editora Teste XOAI</dc:publisher>
   <dc:source>Gaceta Sanitaria, 2025</dc:source>
   <about>
      <provenance>
         <originDescription altered="" harvestDate="">
            <baseURL />
            <identifier>S0001-37652025001201003</identifier>
            <datestamp>2025-12-05T14:44:59.593840+00:00</datestamp>
            <metadataNamespace>http://www.openarchives.org/OAI/2.0/oai_dc/</metadataNamespace>
            <repositoryID />
         </originDescription>
      </provenance>
   </about>
</oai_dc:dc>

Formato MODS gerado

<mods:mods xmlns:doc="http://www.lyncode.com/xoai" xmlns:mods="http://www.loc.gov/mods/v3" xsi:schemaLocation="http://www.loc.gov/mods/v3 http://www.loc.gov/standards/mods/v3/mods-3-1.xsd">
   <mods:name>
      <mods:namePart>MARINA F. MOREIRA</mods:namePart>
   </mods:name>
   <mods:name>
      <mods:namePart>CECÍLIA G. LEAL</mods:namePart>
   </mods:name>
   <mods:name>
      <mods:namePart>PAULO S. POMPEU</mods:namePart>
   </mods:name>
   <mods:extension>
      <mods:dateAvailable encoding="iso8601">2025-12-05T14:44:59.593840+00:00</mods:dateAvailable>
   </mods:extension>
   <mods:extension>
      <mods:dateAccessioned encoding="iso8601">2025-11-10T11:02:57.696802+00:00</mods:dateAccessioned>
   </mods:extension>
   <mods:originInfo>
      <mods:dateIssued encoding="iso8601">2025-11-17</mods:dateIssued>
   </mods:originInfo>
   <mods:identifier type="doi">10.1590/0001-3765202520241229</mods:identifier>
   <mods:identifier type="uri">http://www.scielosp.org/scielo.php?script=sci_arttext&amp;pid=S0001-37652025001201003&amp;tlng=en</mods:identifier>
   <mods:abstract>Abstract Although the contamination of microplastics is a very recent topic, knowledge increased rapidly, especially in the last decade. Despite this, freshwater ecosystems have received less attention than marine ones, particularly in the tropics. Considering the particularities of Tropical freshwater ecosystems that can be important in the microplastics dynamic, such as the high rate of untreated water, the flooding dynamics and high number of reservoirs, our review aims to present the state of the research of microplastic contamination in Tropical freshwater ecosystems, emphasizing the knowledge advances and existing gaps. We compared studies in different countries, ecosystems and type of samples, and identified gaps and needs for futures research. Although research and the complexity of studies have increased over the years, Tropical freshwater ecosystems are still understudied. We emphasized the need for more studies in African countries and Tropical Australia, as well as in reservoirs across all Tropical regions. It is also crucial to evaluate contamination related to flooding dynamics and in aquatic invertebrates. Advancements in research on this topic are essential to provide a clear picture of the real problem in the tropics, leading to the possibility of better mitigation and conservation actions in the future.</mods:abstract>
   <mods:language>
      <mods:languageTerm>en</mods:languageTerm>
   </mods:language>
   <mods:accessCondition type="useAndReproduction">CC BY 4.0</mods:accessCondition>
   <mods:subject>
      <mods:topic>plastic pollution</mods:topic>
   </mods:subject>
   <mods:subject>
      <mods:topic>Aquatic environment</mods:topic>
   </mods:subject>
   <mods:subject>
      <mods:topic>bibliometric review</mods:topic>
   </mods:subject>
   <mods:subject>
      <mods:topic>Tropical ecosystems</mods:topic>
   </mods:subject>
   <mods:titleInfo>
      <mods:title>Trends and gaps in microplastics research in Tropical freshwater ecosystems</mods:title>
   </mods:titleInfo>
   <mods:genre>research-article</mods:genre>
</mods:mods>

XML após compatibilidade com Biodiversity Heritage Library

<mods:mods xmlns:doc="http://www.lyncode.com/xoai" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:mods="http://www.loc.gov/mods/v3" xsi:schemaLocation="http://www.loc.gov/mods/v3 http://www.loc.gov/standards/mods/v3/mods-3-1.xsd">
   <mods:name type="personal">
      <mods:namePart>MARINA F. MOREIRA</mods:namePart>
      <mods:affiliation>Universidade Federal de Lavras, Departamento de Ecologia e Conservação</mods:affiliation>
      <mods:role>
         <mods:roleTerm type="text">author</mods:roleTerm>
      </mods:role>
      <mods:nameIdentifier type="orcid">0000-0002-6857-1198</mods:nameIdentifier>
   </mods:name>
   <mods:name type="personal">
      <mods:namePart>CECÍLIA G. LEAL</mods:namePart>
      <mods:affiliation>Lancaster Environmental Centr, Lancaster University</mods:affiliation>
      <mods:role>
         <mods:roleTerm type="text">author</mods:roleTerm>
      </mods:role>
      <mods:nameIdentifier type="orcid">0000-0002-0108-8572</mods:nameIdentifier>
   </mods:name>
   <mods:name type="personal">
      <mods:namePart>PAULO S. POMPEU</mods:namePart>
      <mods:affiliation>Universidade Federal de Lavras, Departamento de Ecologia e Conservação</mods:affiliation>
      <mods:role>
         <mods:roleTerm type="text">author</mods:roleTerm>
      </mods:role>
      <mods:nameIdentifier type="orcid">0000-0002-7938-1517</mods:nameIdentifier>
   </mods:name>
   <mods:extension>
      <mods:dateAvailable encoding="iso8601">2025-11-10T11:02:57.696802+00:00</mods:dateAvailable>
   </mods:extension>
   <mods:extension>
      <mods:dateAccessioned encoding="iso8601">2025-12-05T14:44:59.593840+00:00</mods:dateAccessioned>
   </mods:extension>
   <mods:originInfo>
      <mods:dateIssued encoding="iso8601">2025-11-17</mods:dateIssued>
   </mods:originInfo>
   <mods:identifier type="doi">10.1590/0001-3765202520241229</mods:identifier>
   <mods:identifier type="uri">http://www.scielosp.org/scielo.php?script=sci_arttext&amp;pid=S0001-37652025001201003&amp;tlng=en</mods:identifier>
   <mods:abstract>Abstract Although the contamination of microplastics is a very recent topic, knowledge increased rapidly, especially in the last decade. Despite this, freshwater ecosystems have received less attention than marine ones, particularly in the tropics. Considering the particularities of Tropical freshwater ecosystems that can be important in the microplastics dynamic, such as the high rate of untreated water, the flooding dynamics and high number of reservoirs, our review aims to present the state of the research of microplastic contamination in Tropical freshwater ecosystems, emphasizing the knowledge advances and existing gaps. We compared studies in different countries, ecosystems and type of samples, and identified gaps and needs for futures research. Although research and the complexity of studies have increased over the years, Tropical freshwater ecosystems are still understudied. We emphasized the need for more studies in African countries and Tropical Australia, as well as in reservoirs across all Tropical regions. It is also crucial to evaluate contamination related to flooding dynamics and in aquatic invertebrates. Advancements in research on this topic are essential to provide a clear picture of the real problem in the tropics, leading to the possibility of better mitigation and conservation actions in the future.</mods:abstract>
   <mods:language>
      <mods:languageTerm type="code" authority="iso639-2b">en</mods:languageTerm>
   </mods:language>
   <mods:accessCondition type="use and reproduction" xlink:href="http://creativecommons.org/licenses/by/4.0/">CC BY 4.0</mods:accessCondition>
   <mods:subject>
      <mods:topic>plastic pollution</mods:topic>
   </mods:subject>
   <mods:subject>
      <mods:topic>Aquatic environment</mods:topic>
   </mods:subject>
   <mods:subject>
      <mods:topic>bibliometric review</mods:topic>
   </mods:subject>
   <mods:subject>
      <mods:topic>Tropical ecosystems</mods:topic>
   </mods:subject>
   <mods:titleInfo>
      <mods:title>Trends and gaps in microplastics research in Tropical freshwater ecosystems</mods:title>
   </mods:titleInfo>
   <mods:genre authority="marcgt">article</mods:genre>
   <mods:typeOfResource>text</mods:typeOfResource>
   <mods:relatedItem type="host">
      <mods:titleInfo>
         <mods:title>Gaceta Sanitaria</mods:title>
      </mods:titleInfo>
      <mods:originInfo>
         <mods:publisher>Editora Teste XOAI</mods:publisher>
      </mods:originInfo>
      <mods:part>
         <mods:date>2025</mods:date>
      </mods:part>
   </mods:relatedItem>
   <mods:location>
      <mods:url usage="primary display" access="object in context">http://www.scielosp.org/scielo.php?script=sci_arttext&amp;pid=S0001-37652025001201003&amp;tlng=en</mods:url>
      <mods:physicalLocation>SciELO Network</mods:physicalLocation>
   </mods:location>
   <mods:note type="funding">CAPES grant 001</mods:note>
   <mods:note type="funding">UKRI Future Leaders Fellowships grant MR/W011085/1</mods:note>
   <mods:note type="funding">CNPq grant 302328/2022–0</mods:note>
</mods:mods>

Referências

Dublin Core:

OAI-PMH:

Framework:

<!-- ========== SOURCE ========== -->
<element name="source">
<element name="none">
<field name="value">{{ object.journal.title }}{% if object.issue.volume %}, v.{{ object.issue.volume }}{% endif %}{% if object.issue.number %}, n.{{ object.issue.number }}{% endif %}{% if object.first_page and object.last_page %}, p.{{ object.first_page }}-{{ object.last_page }}{% endif %}{% if object.pub_date_year %}, {{ object.pub_date_year }}{% endif %}</field>
Copy link
Member

Choose a reason for hiding this comment

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

@Rossi-Luciano apesar de não existir um campo, há o property Article.source. Não funcionou?

<!-- URL da licença (mapeamento Creative Commons) -->
<element name="uri">
<element>
{% if 'CC BY 4.0' in object.license.license_type or 'CC-BY 4.0' in object.license.license_type %}
Copy link
Member

Choose a reason for hiding this comment

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

@Rossi-Luciano criei o Article.license_url (property) para simplificar este código

Comment on lines +155 to +159
{% if ph.institution %}
<field name="value">{{ ph.institution.institution.institution_identification.name }}</field>
{% elif ph.organization %}
<field name="value">{{ ph.organization.name }}</field>
{% endif %}
Copy link
Member

Choose a reason for hiding this comment

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

@Rossi-Luciano dar prioridade para organization que conterá dados padronizados

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This pull request modifies the OAI-PMH template for article metadata generation to fix several field mapping issues and improve compatibility with OAI_DC and MODS formats. The changes address incorrect field paths, add proper Dublin Core qualifiers, and expand metadata elements to better support both metadata standards.

Changes:

  • Corrects field access patterns for publisher, source, rights, and description metadata by fixing ForeignKey vs ManyToMany usage and invalid model paths
  • Restructures Dublin Core elements with proper qualifiers (e.g., dc:contributor/author, dc:language/iso, dc:description/abstract) and adds new metadata sections for citation, relation, and funding
  • Expands date fields to include issued, accessioned, and available qualifiers, and adds ISSN identifier elements with proper print/electronic distinction

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +246 to +261
{% if 'CC BY 4.0' in object.license.license_type or 'CC-BY 4.0' in object.license.license_type %}
<field name="value">http://creativecommons.org/licenses/by/4.0/</field>
{% elif 'CC BY-NC 4.0' in object.license.license_type or 'CC-BY-NC 4.0' in object.license.license_type %}
<field name="value">http://creativecommons.org/licenses/by-nc/4.0/</field>
{% elif 'CC BY-SA 4.0' in object.license.license_type or 'CC-BY-SA 4.0' in object.license.license_type %}
<field name="value">http://creativecommons.org/licenses/by-sa/4.0/</field>
{% elif 'CC BY-ND 4.0' in object.license.license_type or 'CC-BY-ND 4.0' in object.license.license_type %}
<field name="value">http://creativecommons.org/licenses/by-nd/4.0/</field>
{% elif 'CC BY-NC-SA 4.0' in object.license.license_type or 'CC-BY-NC-SA 4.0' in object.license.license_type %}
<field name="value">http://creativecommons.org/licenses/by-nc-sa/4.0/</field>
{% elif 'CC BY-NC-ND 4.0' in object.license.license_type or 'CC-BY-NC-ND 4.0' in object.license.license_type %}
<field name="value">http://creativecommons.org/licenses/by-nc-nd/4.0/</field>
{% elif 'CC BY 3.0' in object.license.license_type or 'CC-BY 3.0' in object.license.license_type %}
<field name="value">http://creativecommons.org/licenses/by/3.0/</field>
{% elif 'CC BY-NC 3.0' in object.license.license_type or 'CC-BY-NC 3.0' in object.license.license_type %}
<field name="value">http://creativecommons.org/licenses/by-nc/3.0/</field>
Copy link

Copilot AI Jan 20, 2026

Choose a reason for hiding this comment

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

The license type string matching logic uses multiple conditions with 'in' checks for different hyphenation formats (e.g., 'CC BY 4.0' and 'CC-BY 4.0'). This approach is brittle and could produce incorrect matches. For example, 'CC BY-NC 4.0' would match the condition for 'CC BY 4.0' on line 246 because 'CC BY 4.0' is a substring of 'CC BY-NC 4.0'. The conditions should be reordered to check more specific licenses first (those with more components like CC BY-NC-ND, CC BY-NC-SA, CC BY-NC, CC BY-SA, CC BY-ND) before checking less specific ones (CC BY), or use exact string matching with multiple elif conditions for each variant.

Suggested change
{% if 'CC BY 4.0' in object.license.license_type or 'CC-BY 4.0' in object.license.license_type %}
<field name="value">http://creativecommons.org/licenses/by/4.0/</field>
{% elif 'CC BY-NC 4.0' in object.license.license_type or 'CC-BY-NC 4.0' in object.license.license_type %}
<field name="value">http://creativecommons.org/licenses/by-nc/4.0/</field>
{% elif 'CC BY-SA 4.0' in object.license.license_type or 'CC-BY-SA 4.0' in object.license.license_type %}
<field name="value">http://creativecommons.org/licenses/by-sa/4.0/</field>
{% elif 'CC BY-ND 4.0' in object.license.license_type or 'CC-BY-ND 4.0' in object.license.license_type %}
<field name="value">http://creativecommons.org/licenses/by-nd/4.0/</field>
{% elif 'CC BY-NC-SA 4.0' in object.license.license_type or 'CC-BY-NC-SA 4.0' in object.license.license_type %}
<field name="value">http://creativecommons.org/licenses/by-nc-sa/4.0/</field>
{% elif 'CC BY-NC-ND 4.0' in object.license.license_type or 'CC-BY-NC-ND 4.0' in object.license.license_type %}
<field name="value">http://creativecommons.org/licenses/by-nc-nd/4.0/</field>
{% elif 'CC BY 3.0' in object.license.license_type or 'CC-BY 3.0' in object.license.license_type %}
<field name="value">http://creativecommons.org/licenses/by/3.0/</field>
{% elif 'CC BY-NC 3.0' in object.license.license_type or 'CC-BY-NC 3.0' in object.license.license_type %}
<field name="value">http://creativecommons.org/licenses/by-nc/3.0/</field>
{% if 'CC BY-NC-ND 4.0' in object.license.license_type or 'CC-BY-NC-ND 4.0' in object.license.license_type %}
<field name="value">http://creativecommons.org/licenses/by-nc-nd/4.0/</field>
{% elif 'CC BY-NC-SA 4.0' in object.license.license_type or 'CC-BY-NC-SA 4.0' in object.license.license_type %}
<field name="value">http://creativecommons.org/licenses/by-nc-sa/4.0/</field>
{% elif 'CC BY-NC 4.0' in object.license.license_type or 'CC-BY-NC 4.0' in object.license.license_type %}
<field name="value">http://creativecommons.org/licenses/by-nc/4.0/</field>
{% elif 'CC BY-SA 4.0' in object.license.license_type or 'CC-BY-SA 4.0' in object.license.license_type %}
<field name="value">http://creativecommons.org/licenses/by-sa/4.0/</field>
{% elif 'CC BY-ND 4.0' in object.license.license_type or 'CC-BY-ND 4.0' in object.license.license_type %}
<field name="value">http://creativecommons.org/licenses/by-nd/4.0/</field>
{% elif 'CC BY 4.0' in object.license.license_type or 'CC-BY 4.0' in object.license.license_type %}
<field name="value">http://creativecommons.org/licenses/by/4.0/</field>
{% elif 'CC BY-NC 3.0' in object.license.license_type or 'CC-BY-NC 3.0' in object.license.license_type %}
<field name="value">http://creativecommons.org/licenses/by-nc/3.0/</field>
{% elif 'CC BY 3.0' in object.license.license_type or 'CC-BY 3.0' in object.license.license_type %}
<field name="value">http://creativecommons.org/licenses/by/3.0/</field>

Copilot uses AI. Check for mistakes.
xsi:schemaLocation="http://www.lyncode.com/xoai http://www.lyncode.com/xsd/xoai.xsd">

<!-- ================================================================== -->
<!-- DUBLIN CORE (OAI_DC) - Metadados básicos para interoperabilidade -->
Copy link

Copilot AI Jan 20, 2026

Choose a reason for hiding this comment

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

Typo in comment: 'AOI_DC' should be 'OAI_DC' (Open Archives Initiative - Dublin Core)

Copilot uses AI. Check for mistakes.
Comment on lines +120 to +121
{% for kwd in object.keywords.all %}
<field name="value" vocabulary="{{ kwd.vocabulary.acronym }}">{{ kwd.text }}</field>
Copy link

Copilot AI Jan 20, 2026

Choose a reason for hiding this comment

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

Line 121 accesses kwd.vocabulary.acronym without checking if vocabulary is null. Since vocabulary is a nullable ForeignKey on the Keyword model, this could cause a template error if a keyword doesn't have an associated vocabulary. Consider adding a conditional check or using a default filter.

Suggested change
{% for kwd in object.keywords.all %}
<field name="value" vocabulary="{{ kwd.vocabulary.acronym }}">{{ kwd.text }}</field>
{% for kwd in object.keywords.all %}
{% if kwd.vocabulary %}
<field name="value" vocabulary="{{ kwd.vocabulary.acronym }}">{{ kwd.text }}</field>
{% else %}
<field name="value">{{ kwd.text }}</field>
{% endif %}

Copilot uses AI. Check for mistakes.
Comment on lines +128 to +135
<!-- Abstract específico (CRÍTICO para MODS!) -->
<element name="abstract">
{% for abs in object.abstracts.all %}
<element>
<field name="value">{{ abs.plain_text }}</field>
</element>
{% endfor %}
</element>
Copy link

Copilot AI Jan 20, 2026

Choose a reason for hiding this comment

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

The comment on line 128 states 'Abstract específico (CRÍTICO para MODS!)' which suggests this is critical for MODS format. However, the element is named 'abstract' which is a qualifier under 'description', following Dublin Core convention. This is appropriate for OAI_DC but should be verified against MODS requirements. According to MODS schema, abstracts should be in mods:abstract elements directly, not under description qualifiers. Consider reviewing if this structure properly supports both OAI_DC and MODS formats as intended.

Copilot uses AI. Check for mistakes.
Comment on lines +167 to +172
<!-- Título do periódico -->
<element name="ispartof">
<element>
<field name="value">{{ object.journal.title }}</field>
</element>
</element>
Copy link

Copilot AI Jan 20, 2026

Choose a reason for hiding this comment

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

Line 170 accesses object.journal.title without checking if object.journal is null. Since the journal field on Article is nullable (null=True, blank=True), this could cause a template error if an article doesn't have an associated journal. Consider wrapping this section in a conditional check {% if object.journal %} or using a default filter.

Suggested change
<!-- Título do periódico -->
<element name="ispartof">
<element>
<field name="value">{{ object.journal.title }}</field>
</element>
</element>
<!-- Título do periódico -->
{% if object.journal %}
<element name="ispartof">
<element>
<field name="value">{{ object.journal.title }}</field>
</element>
</element>
{% endif %}

Copilot uses AI. Check for mistakes.
Comment on lines +155 to +157
{% if ph.institution %}
<field name="value">{{ ph.institution.institution.institution_identification.name }}</field>
{% elif ph.organization %}
Copy link

Copilot AI Jan 20, 2026

Choose a reason for hiding this comment

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

The publisher extraction accesses deep nullable relationships (ph.institution.institution.institution_identification.name and ph.organization.name) without null checks beyond verifying ph and the top-level fields exist. If institution or institution_identification is null in the institution branch, this will cause a template error. Consider adding nested conditional checks to verify the entire chain is not null before accessing the name field.

Suggested change
{% if ph.institution %}
<field name="value">{{ ph.institution.institution.institution_identification.name }}</field>
{% elif ph.organization %}
{% if ph.institution and ph.institution.institution and ph.institution.institution.institution_identification %}
<field name="value">{{ ph.institution.institution.institution_identification.name }}</field>
{% elif ph.organization and ph.organization.name %}

Copilot uses AI. Check for mistakes.
Comment on lines +29 to +31
<field name="value" orcid="{{ research.orcid }}"{% if research.affiliation %} affiliation="{{ research.affiliation.institution.institution_identification.name }}{% if research.affiliation.institution.level_1 %}, {{ research.affiliation.institution.level_1 }}{% endif %}"{% endif %}>{{ research.person_name }}</field>
{% else %}
<field name="value"{% if research.affiliation %} affiliation="{{ research.affiliation.institution.institution_identification.name }}{% if research.affiliation.institution.level_1 %}, {{ research.affiliation.institution.level_1 }}{% endif %}"{% endif %}>{{ research.person_name }}</field>
Copy link

Copilot AI Jan 20, 2026

Choose a reason for hiding this comment

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

The affiliation display accesses a deep chain of nullable relationships (research.affiliation.institution.institution_identification.name and research.affiliation.institution.level_1) without complete null checks. While there's a check for research.affiliation, if institution or institution_identification is null, this will cause a template error. Consider adding nested conditional checks or using Django's template filter 'default' to handle null values gracefully.

Suggested change
<field name="value" orcid="{{ research.orcid }}"{% if research.affiliation %} affiliation="{{ research.affiliation.institution.institution_identification.name }}{% if research.affiliation.institution.level_1 %}, {{ research.affiliation.institution.level_1 }}{% endif %}"{% endif %}>{{ research.person_name }}</field>
{% else %}
<field name="value"{% if research.affiliation %} affiliation="{{ research.affiliation.institution.institution_identification.name }}{% if research.affiliation.institution.level_1 %}, {{ research.affiliation.institution.level_1 }}{% endif %}"{% endif %}>{{ research.person_name }}</field>
<field name="value" orcid="{{ research.orcid }}"{% if research.affiliation and research.affiliation.institution and research.affiliation.institution.institution_identification %} affiliation="{{ research.affiliation.institution.institution_identification.name }}{% if research.affiliation.institution.level_1 %}, {{ research.affiliation.institution.level_1 }}{% endif %}"{% endif %}>{{ research.person_name }}</field>
{% else %}
<field name="value"{% if research.affiliation and research.affiliation.institution and research.affiliation.institution.institution_identification %} affiliation="{{ research.affiliation.institution.institution_identification.name }}{% if research.affiliation.institution.level_1 %}, {{ research.affiliation.institution.level_1 }}{% endif %}"{% endif %}>{{ research.person_name }}</field>

Copilot uses AI. Check for mistakes.
</element>

<!-- ========== PUBLISHER ========== -->
{% with ph=object.journal.publisher_history.first %}
Copy link

Copilot AI Jan 20, 2026

Choose a reason for hiding this comment

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

Line 151 accesses object.journal.publisher_history without checking if object.journal is null. Since the journal field is nullable, this could cause a template error. The {% with %} block should include a null check for object.journal before accessing its publisher_history.

Copilot uses AI. Check for mistakes.
Comment on lines +271 to +274
{% for funding in object.fundings.all %}
<element>
<field name="value">{{ funding.funding_source.institution.institution_identification.name }}{% if funding.award_id %} grant {{ funding.award_id }}{% endif %}</field>
</element>
Copy link

Copilot AI Jan 20, 2026

Choose a reason for hiding this comment

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

The funding section accesses a deep chain of nullable relationships (funding.funding_source.institution.institution_identification.name) without null checks. If any intermediate relationship is null, this will cause a template error. Consider adding conditional checks to ensure funding_source, institution, and institution_identification are not None before accessing the name field.

Suggested change
{% for funding in object.fundings.all %}
<element>
<field name="value">{{ funding.funding_source.institution.institution_identification.name }}{% if funding.award_id %} grant {{ funding.award_id }}{% endif %}</field>
</element>
{% for funding in object.fundings.all %}
{% if funding.funding_source and funding.funding_source.institution and funding.funding_source.institution.institution_identification %}
<element>
<field name="value">{{ funding.funding_source.institution.institution_identification.name }}{% if funding.award_id %} grant {{ funding.award_id }}{% endif %}</field>
</element>
{% endif %}

Copilot uses AI. Check for mistakes.
<!-- ========== SOURCE ========== -->
<element name="source">
<element name="none">
<field name="value">{{ object.journal.title }}{% if object.issue.volume %}, v.{{ object.issue.volume }}{% endif %}{% if object.issue.number %}, n.{{ object.issue.number }}{% endif %}{% if object.first_page and object.last_page %}, p.{{ object.first_page }}-{{ object.last_page }}{% endif %}{% if object.pub_date_year %}, {{ object.pub_date_year }}{% endif %}</field>
Copy link

Copilot AI Jan 20, 2026

Choose a reason for hiding this comment

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

Line 231 accesses object.issue.volume and object.issue.number in the source citation without checking if object.issue is null. Since the issue field is nullable, this could cause a template error. Consider adding a conditional check or restructuring the source generation logic to handle null issue safely.

Copilot uses AI. Check for mistakes.
<element name="author">
{% for research in object.researchers.all %}
<element>
{% if research.orcid %}
Copy link
Member

@robertatakenaka robertatakenaka Jan 20, 2026

Choose a reason for hiding this comment

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

@Rossi-Luciano deixe o código mais enxuto aqui. Transfira a complexidade para o modelo Researcher, assim como foi feito para Article.source ou Article.license_url (ambos property). O Article.license_url ficará disponível em um futuro PR meu

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants