-
Notifications
You must be signed in to change notification settings - Fork 10
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
Refactor: simplify Eligibility Start templates #2726
Conversation
656e62f
to
380e89a
Compare
Coverage reportClick to see where and how coverage changed
This report was generated by python-coverage-comment-action |
5411cf0
to
6d60b5c
Compare
extra_classes is helpful when we have additional styling to do for a particular type of EligibilityStart.
6d60b5c
to
25bc8e4
Compare
Preview url: https://benefits-2726--cal-itp-previews.netlify.app |
c113f0e
to
4fc9821
Compare
EnrollmentFlow model was updated to replace eligibility_start_template_override with eligibility_start_context.
they kept failing with an error saying that `eligibility_start_context` was a MagicMock instead of a dict. when running with a debugger, I could see that `session.flow` returns a MagicMock. maybe that was fine before, but now we need to use the actual test model instance.
4fc9821
to
57f2faf
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good to me! I liked the organization/cleanup in 0b3c428 and 6e067f9
Also tested locally and compared it on the browser with https://dev-benefits.calitp.org/ and the Eligibility Start page looked identical 👍
class EligibilityStart: | ||
page_title: str | ||
headline_text: str | ||
eligibility_item_template: str |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we can take a follow-up item to refactor this field away from using these templates, and to encode the item strings directly in context.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, great idea! Created #2759 for it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I put it in the sprint, but feel free to change that if you disagree
{% include "eligibility/includes/eligibility-item--contactless-card--start.html" %} | ||
</ul> | ||
{% endblock inner-content %} | ||
|
||
{% block call-to-action-button %} | ||
{% translate call_to_action_button.text as button_text %} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is something I was wondering about when working on #2753:
Since we already use the gettext()
helper (aliased as _()
) setting up the context, to mark the string as translatable -- do we also need to translate the string in the template with this {% translate %}
(or {% blocktranslate %}
tag?
I think the answer, from #2753 anyway, seems to be: no. You can just render the variable directly in the template and it will be translated as necessary. E.g. this template change: https://github.com/cal-itp/benefits/pull/2753/files#diff-70ed6fd5fa2321e83db0d63df8312f680cd40428de4ada50dab22e93f55db7c7R109
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree that we can remove translate
from the templates 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm thinking to merge this PR as-is, and a follow-up PR can remove the unnecessary translate
s in the templates
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Created #2760 as that follow-up ticket
Closes #2728
This PR refactors the
eligibility.start
view so that it uses a single template. It uses a context dictionary from the flow to provide the template with copy.The
EligibilityStart
class models the pieces of copy that are needed for the page. I noticed enough duplication with the Login.gov-based instances and also with the agency-card instances ofEligibilityStart
, so I decided to create subclasses -LoginGovEligibilityStart
andAgencyCardEligibilityStart
- to consolidate the copy that was being duplicated.Testing locally
./bin/init.sh