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

Refactor: agency selection backend #1204

Merged
merged 3 commits into from
Jan 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
18 changes: 18 additions & 0 deletions benefits/core/migrations/0002_sample_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,24 @@ def load_sample_data(app, *args, **kwargs):
mst_agency.eligibility_types.set([senior_type, courtesy_card_type])
mst_agency.eligibility_verifiers.set([oauth_claims_verifier, courtesy_card_verifier])

sacrt_agency = TransitAgency.objects.create(
slug="sacrt",
short_name=os.environ.get("SACRT_AGENCY_SHORT_NAME", "SacRT (sample)"),
long_name=os.environ.get("SACRT_AGENCY_LONG_NAME", "Sacramento Regional Transit (sample)"),
agency_id="sacrt",
merchant_id="sacrt",
info_url="https://sacrt.com/",
phone="916-321-2877",
active=True,
private_key=client_private_key,
public_key=client_public_key,
jws_signing_alg=os.environ.get("SACRT_AGENCY_JWS_SIGNING_ALG", "RS256"),
payment_processor=payment_processor,
eligibility_index_intro=_("eligibility.pages.index.p[0].sacrt"),
)
sacrt_agency.eligibility_types.set([senior_type])
sacrt_agency.eligibility_verifiers.set([oauth_claims_verifier])


class Migration(migrations.Migration):

Expand Down
5 changes: 5 additions & 0 deletions benefits/core/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,11 @@ def index_url(self):
"""Public-facing URL to the TransitAgency's landing page."""
return reverse("core:agency_index", args=[self.slug])

@property
def eligibility_index_url(self):
"""Public facing URL to the TransitAgency's eligibility page."""
return reverse("eligibility:agency_index", args=[self.slug])

@property
def public_key_url(self):
"""Public-facing URL to the TransitAgency's public key."""
Expand Down
2 changes: 1 addition & 1 deletion benefits/core/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def index(request):
return redirect(agency.index_url)

# generate a button to the landing page for each active agency
buttons = [viewmodels.Button.outline_primary(text=a.short_name, url=a.index_url) for a in agencies]
buttons = [viewmodels.Button.outline_primary(text=a.short_name, url=a.eligibility_index_url) for a in agencies]
buttons[0].classes.append("mt-3")
buttons[0].label = _("core.pages.index.chooseprovider")

Expand Down
1 change: 1 addition & 0 deletions benefits/eligibility/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
urlpatterns = [
# /eligibility
path("", views.index, name="index"),
path("<agency:agency>", views.index, name="agency_index"),
path("start", views.start, name="start"),
path("confirm", views.confirm, name="confirm"),
path("unverified", views.unverified, name="unverified"),
Expand Down
14 changes: 11 additions & 3 deletions benefits/eligibility/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,21 @@
TEMPLATE_UNVERIFIED = "eligibility/unverified.html"


@decorator_from_middleware(AgencySessionRequired)
@decorator_from_middleware(RecaptchaEnabled)
def index(request):
def index(request, agency=None):
"""View handler for the eligibility verifier selection form."""

if agency is None:
# see if session has an agency
agency = session.agency(request)
if agency is None:
home = viewmodels.Button.home(request)
page = viewmodels.ErrorPage.user_error(button=home, path=request.path)
return TemplateResponse(request, "200_user_error.html", page.context_dict())
else:
session.update(request, agency=agency)

session.update(request, eligibility_types=[], origin=reverse(ROUTE_INDEX))
agency = session.agency(request)

eligibility_start = reverse(ROUTE_START)

Expand Down
7 changes: 6 additions & 1 deletion benefits/locale/en/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
msgid ""
msgstr ""
"Report-Msgid-Bugs-To: https://github.com/cal-itp/benefits/issues \n"
"POT-Creation-Date: 2023-01-12 00:44+0000\n"
"POT-Creation-Date: 2023-01-13 17:24+0000\n"
"Language: English\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
Expand Down Expand Up @@ -145,6 +145,11 @@ msgstr ""
"You can tap your credit or debit card when you board an MST bus, and your "
"discounted fare will automatically apply every time you ride. "

msgid "eligibility.pages.index.p[0].sacrt"
msgstr ""
"You can tap your credit or debit card when you board a SacRT bus, and your "
"discounted fare will automatically apply every time you ride. "

msgid "core.pages.agency_index.h2"
msgstr "Your benefit applies every time you tap to ride"

Expand Down
7 changes: 6 additions & 1 deletion benefits/locale/es/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
msgid ""
msgstr ""
"Report-Msgid-Bugs-To: https://github.com/cal-itp/benefits/issues \n"
"POT-Creation-Date: 2023-01-12 00:44+0000\n"
"POT-Creation-Date: 2023-01-13 17:24+0000\n"
"Language: Español\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
Expand Down Expand Up @@ -152,6 +152,11 @@ msgstr ""
"Puede acercar su tarjeta de crédito o débito cuando aborde un autobús de MST "
"y su tarifa con descuento se aplicará automáticamente cada vez que viaje. "

msgid "eligibility.pages.index.p[0].sacrt"
msgstr ""
"Puede acercar su tarjeta de crédito o débito cuando aborde un autobús de SacRT "
"y su tarifa con descuento se aplicará automáticamente cada vez que viaje. "

msgid "core.pages.agency_index.h2"
msgstr "Su beneficio se aplicará cada vez que acerque su tarjeta para viajar"

Expand Down