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

Feat: enrollments can expire #2165

Merged
merged 2 commits into from
Jun 20, 2024
Merged

Feat: enrollments can expire #2165

merged 2 commits into from
Jun 20, 2024

Conversation

angela-tran
Copy link
Member

Closes #2062

This PR reverts "Revert "Feat: enrollments can expire (#1989)" (#2052)".

There were merge conflicts with various features and refactors that were done since #2052, and I think I resolved them all correctly. (Examples are system enrollment error logic and enrollment success template refactor.)

@angela-tran angela-tran self-assigned this Jun 13, 2024
@github-actions github-actions bot added tests Related to automated testing (unit, UI, integration, etc.) back-end Django views, sessions, middleware, models, migrations etc. deployment-dev [auto] Changes that will trigger a deploy if merged to dev labels Jun 13, 2024
Copy link

github-actions bot commented Jun 13, 2024

Coverage report

Click to see where and how coverage changed

FileStatementsMissingCoverageCoverage
(new stmts)
Lines missing
  benefits
  settings.py
  benefits/enrollment
  views.py
Project Total  

This report was generated by python-coverage-comment-action

@angela-tran
Copy link
Member Author

I manually tested the expiration scenarios in enrollment:index using the MST Courtesy Card group in QA. With the fix from cal-itp/littlepay#64, they work for me.

if eligibility.supports_expiration:
# set expiry on session
if already_enrolled and group_funding_source.expiry_date is not None:
session.update(request, enrollment_expiry=group_funding_source.expiry_date)
else:
session.update(request, enrollment_expiry=_calculate_expiry(eligibility.expiration_days))
if not already_enrolled:
# enroll user with an expiration date, return success
client.link_concession_group_funding_source(
group_id=group_id, funding_source_id=funding_source.id, expiry=session.enrollment_expiry(request)
)
return success(request)
else: # already_enrolled
if group_funding_source.expiry_date is None:
# update expiration of existing enrollment, return success
client.update_concession_group_funding_source_expiry(
group_id=group_id,
funding_source_id=funding_source.id,
expiry=session.enrollment_expiry(request),
)
return success(request)
else:
is_expired = _is_expired(group_funding_source.expiry_date)
is_within_reenrollment_window = _is_within_reenrollment_window(
group_funding_source.expiry_date, session.enrollment_reenrollment(request)
)
if is_expired or is_within_reenrollment_window:
# update expiration of existing enrollment, return success
client.update_concession_group_funding_source_expiry(
group_id=group_id,
funding_source_id=funding_source.id,
expiry=session.enrollment_expiry(request),
)
return success(request)
else:
# re-enrollment error, return enrollment error with expiration and reenrollment_date
return reenrollment_error(request)

@angela-tran angela-tran marked this pull request as ready for review June 14, 2024 19:35
@angela-tran angela-tran requested a review from a team as a code owner June 14, 2024 19:35
@angela-tran
Copy link
Member Author

Rebased on top of latest dev

Copy link
Member

@lalver1 lalver1 left a comment

Choose a reason for hiding this comment

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

I was able to test the different expiration scenarios for enrollments and they worked. Looking over the code, everything looked good too 👍

@angela-tran angela-tran merged commit bcb9b1e into dev Jun 20, 2024
15 checks passed
@angela-tran angela-tran deleted the feat/expiry branch June 20, 2024 16:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
back-end Django views, sessions, middleware, models, migrations etc. deployment-dev [auto] Changes that will trigger a deploy if merged to dev tests Related to automated testing (unit, UI, integration, etc.)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Bring back the expiry date logic
2 participants