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

Remove localized from partner html template and moved to get_context #12978

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

Conversation

dlopezvsr
Copy link
Collaborator

@dlopezvsr dlopezvsr commented Oct 8, 2024

Description

This PR removes .localized attribute from partner.html template as part of the localize cleanup. This also moves the logic to page's get_context function context["localized_partner_page"] returning a localized version of the page.

Link to sample test page:
Related PRs/issues: #10011

How to test

  • You can scroll down to the partner section.
  • Click on the link "Let's work together" and make sure the locale is kept.

See images below.
image
image

Checklist

Tests

  • Is the code I'm adding covered by tests?

Changes in Models:

  • Did I update or add new fake data?
  • Did I squash my migration?
  • Are my changes backward-compatible. If not, did I schedule a deploy with the rest of the team?

Documentation:

  • Is my code documented?
  • Did I update the READMEs or wagtail documentation?

Merge Method
💡❗Remember to use squash merge when merging non-feature branches into main

┆Issue is synchronized with this Jira Story

@dlopezvsr dlopezvsr self-assigned this Oct 8, 2024
@dlopezvsr dlopezvsr marked this pull request as ready for review October 8, 2024 18:50
Copy link
Collaborator

@danielfmiranda danielfmiranda left a comment

Choose a reason for hiding this comment

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

Hi @dlopezvsr!

Thank you for taking on this work—everything is looking great and working as expected! 👍

I just have one minor suggestion before we merge, and then it should be good to go.

@@ -11,7 +11,7 @@ <h2 class="tw-h3-heading">{{ page.partner_heading }}</h2>
{{ page.partner_intro_text }}
</p>
{% endif %}
<a href="{{ page.partner_page.localized.url }}" class="text-white tw-cta-link font-weight-bold" id="partner-cta">
<a href="{{ localized_partner_page.url }}" class="text-white tw-cta-link font-weight-bold" id="partner-cta">
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
<a href="{{ localized_partner_page.url }}" class="text-white tw-cta-link font-weight-bold" id="partner-cta">
{% if localized_partner_page %}
<a href="{{ localized_partner_page.url }}" class="text-white tw-cta-link font-weight-bold" id="partner-cta">
{% endif %}

Hi @dlopezvsr, while I was testing this out, I found that even if the "partner_page" was not set, this <a> element was still rendering. However, since there was no localized_partner_page to grab a URL from, it was just linking back to localhost:8000.

Can we please wrap this in a {% if %} statement? That way, this button wont render unless the page is set.

Thanks!

Comment on lines +1016 to +1017
if self.partner_page:
context["localized_partner_page"] = self.partner_page.localized
Copy link
Collaborator

Choose a reason for hiding this comment

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

Kudos Looks good to me. Great job!

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