Skip to content

Commit

Permalink
refactor(enrollment): use agency links include
Browse files Browse the repository at this point in the history
  • Loading branch information
thekaveman committed Jul 12, 2023
1 parent 551529e commit 064d732
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 25 deletions.
16 changes: 0 additions & 16 deletions benefits/core/viewmodels.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,6 @@ def __init__(self, **kwargs):
self.target = kwargs.get("target")
self.rel = kwargs.get("rel")

@staticmethod
def agency_contact_links(agency):
"""Create link buttons for agency contact information."""
return [
Button.link(label=agency.long_name, text=agency.phone, url=f"tel:{agency.phone}"),
Button.link(text=agency.info_url, url=agency.info_url, target="_blank", rel="noopener noreferrer"),
]

@staticmethod
def home(request, text=None):
"""Create a button back to this session's origin."""
Expand All @@ -53,14 +45,6 @@ def home(request, text=None):

return Button.primary(text=text, url=session.origin(request))

@staticmethod
def link(**kwargs):
classes = kwargs.pop("classes", [])
if isinstance(classes, str):
classes = classes.split(" ")
classes.insert(0, "btn-link")
return Button(classes=classes, **kwargs)

@staticmethod
def primary(**kwargs):
classes = kwargs.pop("classes", [])
Expand Down
14 changes: 7 additions & 7 deletions benefits/enrollment/templates/enrollment/retry.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,16 @@
</div>
</div>

{% if agency_links %}
<div class="row justify-content-center">
<div class="col-lg-8">{% include "core/includes/agency-links.html" with buttons=agency_links %}</div>
</div>
{% if agency and agency.links_template %}
<div class="row justify-content-center">
<div class="col-lg-8">{% include agency.links_template %}</div>
</div>
{% endif %}

{% if retry_button %}
<div class="row pt-8 justify-content-center">
<div class="col-lg-3 col-8">{% include "core/includes/button.html" with button=retry_button %}</div>
</div>
<div class="row pt-8 justify-content-center">
<div class="col-lg-3 col-8">{% include "core/includes/button.html" with button=retry_button %}</div>
</div>
{% endif %}

</div>
Expand Down
2 changes: 0 additions & 2 deletions benefits/enrollment/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,6 @@ def retry(request):
analytics.returned_retry(request)
form = forms.CardTokenizeFailForm(request.POST)
if form.is_valid():
agency = session.agency(request)
page = viewmodels.Page(
title=_("enrollment.pages.retry.title"),
icon=viewmodels.Icon("bankcardquestion", pgettext("image alt text", "core.icons.bankcardquestion")),
Expand All @@ -105,7 +104,6 @@ def retry(request):
)

ctx = page.context_dict()
ctx["agency_links"] = viewmodels.Button.agency_contact_links(agency)
ctx["retry_button"] = viewmodels.Button.primary(text=_("core.buttons.retry"), url=session.origin(request))

return TemplateResponse(request, TEMPLATE_RETRY, ctx)
Expand Down

0 comments on commit 064d732

Please sign in to comment.