Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
329 changes: 257 additions & 72 deletions article/templates/search/indexes/article/article_compile.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,108 +5,293 @@
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
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.
<!-- ================================================================== -->
<element name="dc">

<!-- ========== TITLE ========== -->
<element name="title">
<element name="none">
{% for title in object.titles.all %}
{% for title in object.titles.all %}
<field name="value">{{ title.plain_text }}</field>
{% endfor%}
{% endfor %}
</element>
</element>
<element name="creator">

<!-- ========== CONTRIBUTOR / AUTHOR ========== -->
<element name="contributor">
<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

<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>
Comment on lines +29 to +31
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.
{% endif %}
</element>
{% endfor %}
</element>
</element>

<!-- ========== DATE ========== -->
<element name="date">
<!-- Data de publicação (dateIssued) -->
{% if object.pub_date %}
<element name="issued">
<element>
<field name="value">{{ object.pub_date }}</field>
</element>
</element>
{% endif %}

<!-- Data de acessão ao repositório (dateAccessioned) -->
{% if object.created %}
<element name="accessioned">
<element>
<field name="value">{{ object.created|date:"c" }}</field>
</element>
</element>
{% endif %}

<!-- Data de disponibilização (dateAvailable) -->
{% if object.updated %}
<element name="available">
<element>
<field name="value">{{ object.updated|date:"c" }}</field>
</element>
</element>
{% endif %}
</element>

<!-- ========== IDENTIFIER ========== -->
<element name="identifier">
<!-- PIDs -->
<element name="none">
{% for research in object.researchers.all %}
{% if research.orcid %}
<field name="value" orcid="{{research.orcid}}">{{research.person_name}}</field>
{% else %}
<field name="value">{{research.person_name}}</field>
<field name="value">{{ object.pid_v2 }}</field>
<field name="value">{{ object.pid_v3 }}</field>
</element>

<!-- DOI qualificado -->
<element name="doi">
{% for doi in object.doi.all %}
<element>
<field name="value">{{ doi.value }}</field>
</element>
{% endfor %}
</element>

<!-- ISSN print -->
{% if object.journal.official %}
{% if object.journal.official.issn_print %}
<element name="issn">
<element>
<field name="value">{{ object.journal.official.issn_print }}</field>
</element>
</element>
{% endif %}

<!-- ISSN eletrônico -->
{% if object.journal.official.issn_electronic %}
<element name="eissn">
<element>
<field name="value">{{ object.journal.official.issn_electronic }}</field>
</element>
</element>
{% endif %}
{% endfor %}
{% endif %}
Comment on lines +86 to +103
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.

Lines 86-103 access object.journal.official and its ISSN fields without checking if object.journal is null. Since the journal field is nullable, this could cause a template error. The conditional check should first verify object.journal exists before checking object.journal.official.

Copilot uses AI. Check for mistakes.

<!-- URI qualificado -->
<element name="uri">
{% for collection in object.collections %}
{% for lang in object.languages.all %}
<element>
<field name="value">http://{{ collection.domain }}/scielo.php?script=sci_arttext&amp;pid={{ object.pid_v2 }}&amp;tlng={{ lang.code2 }}</field>
</element>
{% endfor %}
{% endfor %}
Comment on lines +108 to +113
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 nested loops on lines 107-113 generate a URI for every combination of collection and language, which could result in N×M elements. This may create a large number of duplicate or redundant URIs if an article belongs to multiple collections. Consider whether all these URIs are necessary for OAI-PMH metadata, or if a single canonical URI would be more appropriate. This could also impact performance for articles with many collections and languages.

Suggested change
{% for lang in object.languages.all %}
<element>
<field name="value">http://{{ collection.domain }}/scielo.php?script=sci_arttext&amp;pid={{ object.pid_v2 }}&amp;tlng={{ lang.code2 }}</field>
</element>
{% endfor %}
{% endfor %}
<element>
<field name="value">http://{{ collection.domain }}/scielo.php?script=sci_arttext&amp;pid={{ object.pid_v2 }}</field>
</element>
{% endfor %}

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

<!-- ========== SUBJECT ========== -->
<element name="subject">
<element name="none">
{% for kwd in object.keywords.all %}
<field name="value">{{ kwd.text }}</field>
{% endfor %}
{% for kwd in object.keywords.all %}
<field name="value" vocabulary="{{ kwd.vocabulary.acronym }}">{{ kwd.text }}</field>
Comment on lines +120 to +121
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.
{% endfor %}
</element>
</element>

<!-- ========== DESCRIPTION ========== -->
<element name="description">
<!-- 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>
Comment on lines +128 to +135
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.
</element>

<!-- ========== LANGUAGE ========== -->
<element name="language">
<!-- Idioma ISO -->
<element name="iso">
{% for lang in object.languages.all %}
<element>
<field name="value">{{ lang.code2 }}</field>
</element>
{% endfor %}
</element>
</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.
{% if ph %}
<element name="publisher">
<element name="none">
{% if ph.institution %}
<field name="value">{{ ph.institution.institution.institution_identification.name }}</field>
{% elif ph.organization %}
Comment on lines +155 to +157
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.
<field name="value">{{ ph.organization.name }}</field>
{% endif %}
Comment on lines +155 to +159
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

</element>
</element>
{% endif %}
{% endwith %}

<!-- ========== RELATION ========== -->
<element name="relation">
<!-- Título do periódico -->
<element name="ispartof">
<element>
<field name="value">{{ object.journal.title }}</field>
</element>
</element>
Comment on lines +167 to +172
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.
</element>

<!-- ========== CITATION (elementos estruturados) ========== -->
<element name="citation">
<!-- Volume -->
{% if object.issue.volume %}
<element name="volume">
<element>
<field name="value">{{ object.issue.volume }}</field>
</element>
</element>
{% endif %}

<!-- Número/Issue -->
{% if object.issue.number %}
<element name="issue">
<element>
<field name="value">{{ object.issue.number }}</field>
</element>
</element>
{% endif %}

<!-- Página inicial -->
{% if object.first_page %}
<element name="spage">
<element>
<field name="value">{{ object.first_page }}</field>
</element>
</element>
{% endif %}

<!-- Página final -->
{% if object.last_page %}
<element name="epage">
<element>
<field name="value">{{ object.last_page }}</field>
</element>
</element>
{% endif %}
</element>

<!-- ========== TYPE ========== -->
<element name="type">
<element name="none">
{% for abs in object.abstracts.all %}
<field name="value">{{ abs }}</field>
{% endfor %}
<field name="value"/>
<field name="value">{{ object.article_type }}</field>
</element>
</element>
<element name="date">
<element name="none">
<field name="value">{{ object.updated|date:"c" }}</field>
</element>
</element>
<element name="type">
<element name="none">
<field name="value">{{ object.article_type }}</field>
</element>
</element>
<element name="identifier">
<element name="none">

{% for doi in object.doi.all %}
<field name="value">{{ doi.value }}</field>
{% endfor %}

<field name="value">{{ object.pid_v2 }}</field>
<field name="value">{{ object.pid_v3 }}</field>
<!-- ========== FORMAT ========== -->
<element name="format">
<element name="none">
<field name="value">text/html</field>
</element>
</element>

{% for collection in object.collections %}
{% for lang in object.languages.all %}
<field name="value">http://{{collection.domain}}/scielo.php?script=sci_arttext&amp;pid={{object.pid_v2}}&amp;tlng={{lang.code2}}</field>
<!-- ========== 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?

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 dynamic source citation generation on line 231 creates an extremely long single line with multiple conditional concatenations. This makes the template difficult to read and maintain. Consider breaking this into multiple lines using Django template tags like {% with %} blocks or {% filter %} to improve readability, or pre-format this citation in a model property or template filter.

Suggested change
<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>
<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>

Copilot uses AI. Check for mistakes.
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.journal.title in the source citation generation without checking if object.journal is null. Since the journal field is nullable, this could cause a template error. Consider adding a conditional check before accessing journal properties.

Suggested change
<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>
<field name="value">{% if object.journal %}{{ object.journal.title }}{% endif %}{% 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>

Copilot uses AI. Check for mistakes.
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>
</element>

<!-- ========== RIGHTS ========== -->
<element name="rights">
{% if object.license %}
<!-- Texto da licença -->
<element name="none">
<field name="value">{{ object.license.license_type }}</field>
</element>

<!-- 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

<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>
Comment on lines +246 to +261
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.
{% endif %}
</element>
</element>
{% endif %}
</element>

<!-- ========== FUNDING ========== -->
<element name="description">
<element name="sponsorship">
{% 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>
Comment on lines +271 to +274
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.
{% endfor %}
{% endfor %}

</element>
</element>
<element name="language">
<element name="none">
{% for lang in object.languages.all %}
<field name="value">{{ lang.code2 }}</field>
{% endfor %}
</element>
</element>
<element name="rights">
<element name="none">
{% for lic in object.license.all %}
<field name="value">{{ lic }}</field>
{% endfor %}
</element>
</element>
<element name="source">
<element name="none">
<field name="value">{{ object.source }}</field>
</element>
</element>

<element name="publisher">
<element name="none">
<field name="value">{{ object.publisher.institution.institution_identification.name }}</field>
</element>
</element>
<element name="format">
<element name="none">
<field name="value">text/html</field>
</element>
</element>
</element>
</element>
Comment on lines +10 to +277
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 template comments mix Portuguese and English inconsistently. For example, line 10 has 'Metadados básicos para interoperabilidade' (Portuguese), while section headers use English (e.g., 'TITLE', 'CONTRIBUTOR / AUTHOR'). Consider using a single language throughout the comments for better maintainability and consistency.

Copilot uses AI. Check for mistakes.

</element>

<!-- ========== BUNDLES ========== -->
<element name="bundles"/>

<!-- ========== OTHERS ========== -->
<element name="others">
<field name="handle"/>
<field name="identifier">{{ object.pid_v2 }}</field>
<field name="lastModifyDate">{{ object.updated|date:"c" }}</field>
</element>

<!-- ========== REPOSITORY ========== -->
<element name="repository">
<field name="mail"/>
<field name="name"/>
</element>
</metadata>

</metadata>
Loading