Skip to content

Commit

Permalink
refactor(view): remove potentially misleading variables
Browse files Browse the repository at this point in the history
use the specific condition that is leading to the branch of code, which
namely is if the concession expiry is None or not.
  • Loading branch information
angela-tran committed Mar 29, 2024
1 parent 882fd8b commit 15bf0c9
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions benefits/enrollment/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,12 +95,10 @@ def index(request):
)

already_enrolled = group_funding_source is not None
has_no_expiration_date = already_enrolled and group_funding_source.concession_expiry is None
has_expiration_date = already_enrolled and group_funding_source.concession_expiry is not None

if eligibility.supports_expiration:
# set expiry on session
if has_expiration_date:
if already_enrolled and group_funding_source.concession_expiry is not None:
session.update(request, enrollment_expiry=group_funding_source.concession_expiry)
else:
session.update(request, enrollment_expiry=_calculate_expiry(eligibility.expiration_days))
Expand All @@ -111,8 +109,8 @@ def index(request):
group_id=group_id, funding_source_id=funding_source.id, expiry_date=session.enrollment_expiry(request)
)
return _success(request, group_id)
else:
if has_no_expiration_date:
else: # already_enrolled
if group_funding_source.concession_expiry is None:
# update expiration of existing enrollment, return success
client.update_concession_group_funding_source_expiry(
group_id=group_id,
Expand Down Expand Up @@ -142,8 +140,8 @@ def index(request):
# enroll user with no expiration date, return success
client.link_concession_group_funding_source(group_id=group_id, funding_source_id=funding_source.id)
return _success(request, group_id)
else:
if has_no_expiration_date:
else: # already_enrolled
if group_funding_source.concession_expiry is None:
# no action, return success
return _success(request, group_id)
else:
Expand Down

0 comments on commit 15bf0c9

Please sign in to comment.