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

fix: Handle undefined record attributes in templates to avoid rendering errors #2932

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

Samk13
Copy link
Member

@Samk13 Samk13 commented Dec 5, 2024

❤️ Thank you for your contribution!

Description

Checklist

Ticks in all boxes and 🟢 on all GitHub actions status checks are required to merge:

Frontend

Reminder

By using GitHub, you have already agreed to the GitHub’s Terms of Service including that:

  1. You license your contribution under the same terms as the current repository’s license.
  2. You agree that you have the right to license your contribution under the current repository’s license.

@Samk13 Samk13 force-pushed the fix-template-description-check branch from 3c86a5d to b723bc6 Compare December 5, 2024 01:59
@Samk13 Samk13 changed the title fix: improve handling of additional descriptions in detail template fix: Handle undefined record attributes in templates to avoid rendering errors Dec 5, 2024
@Samk13 Samk13 requested a review from tmorrell December 5, 2024 11:34
Copy link
Contributor

@tmorrell tmorrell left a comment

Choose a reason for hiding this comment

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

@Samk13 this is amazing! It's like the fastest fix ever.

I've tested it on our instance and it solves the issue.

@Samk13 Samk13 force-pushed the fix-template-description-check branch 2 times, most recently from 4cc21a0 to 95c5d20 Compare December 6, 2024 11:25
Copy link
Member Author

@Samk13 Samk13 left a comment

Choose a reason for hiding this comment

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

I added separate commits to safely access values. Some of these checks might be unnecessary. If you think it's overkill in certain macros, let me know and I’ll revert them.

* Handle missing 'type' in description rendering
* Add the missing description type when the type is not specified.
* closes inveniosoftware#2931
* fix show_dates
* fix _identifiers_for_group
* fix show_related_identifiers by filtering with selectattr: https://jinja.palletsprojects.com/en/stable/templates/#jinja-filters.selectattr
@Samk13 Samk13 force-pushed the fix-template-description-check branch from 7a953f3 to 4fa5c3e Compare January 17, 2025 13:58
@@ -39,7 +39,7 @@


{% macro show_creatibutors(creatibutors, show_affiliations=False, type="creators", show_role=False) %}
{% for creatibutor in creatibutors %}
{% for creatibutor in creatibutors if creatibutor.person_or_org and creatibutor.person_or_org.name %}
Copy link
Member Author

@Samk13 Samk13 Jan 17, 2025

Choose a reason for hiding this comment

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

While in community review, you can edit a contributor by removing their name but keeping the required role. Upon saving, the reviewer will encounter an error.

@Samk13 Samk13 force-pushed the fix-template-description-check branch from 4fa5c3e to 8f053c0 Compare January 17, 2025 14:33
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.

Incomplete records break community requests
2 participants