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: transit processor portal link for admin dashboard #2370

Merged
merged 8 commits into from
Sep 17, 2024
2 changes: 2 additions & 0 deletions .env.sample
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,5 @@ client_public_key='-----BEGIN PUBLIC KEY-----\nMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AM
cst_transit_processor_client_secret=secret

testsecret="Hello from the local environment!"

SSO_SHOW_FORM_ON_ADMIN_PAGE=True
9 changes: 8 additions & 1 deletion benefits/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,13 @@ def index(self, request, extra_context=None):

if agency is not None:
has_permission_for_in_person = agency.customer_service_group in request.user.groups.all()
context.update({"has_permission_for_in_person": has_permission_for_in_person})
transit_processor_portal_url = agency.transit_processor.portal_url

context.update(
{
"has_permission_for_in_person": has_permission_for_in_person,
"transit_processor_portal_url": transit_processor_portal_url,
}
)

return TemplateResponse(request, "admin/agency-dashboard-index.html", context)
22 changes: 22 additions & 0 deletions benefits/core/migrations/0025_transitprocessor_portal_url.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Generated by Django 5.0.6 on 2024-09-16 20:11

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
("core", "0024_transitagency_sso_domain_customer_service"),
]

operations = [
migrations.AddField(
model_name="transitprocessor",
name="portal_url",
field=models.TextField(
blank=True,
help_text="The absolute base URL for the TransitProcessor's control portal, including https://.",
null=True,
),
),
]
32 changes: 30 additions & 2 deletions benefits/core/migrations/local_fixtures.json
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,8 @@
"api_base_url": "http://server:8000",
"card_tokenize_url": "http://server:8000/static/tokenize.js",
"card_tokenize_func": "tokenize",
"card_tokenize_env": "test"
"card_tokenize_env": "test",
"portal_url": "https://www.transit-processor-portal.com"
}
},
{
Expand All @@ -172,7 +173,34 @@
"transit_processor": 1,
"transit_processor_audience": "",
"transit_processor_client_id": "",
"transit_processor_client_secret_name": "cst-transit-processor-client-secret"
"transit_processor_client_secret_name": "cst-transit-processor-client-secret",
"staff_group": 2,
"customer_service_group": 2
}
},
{
"model": "auth.Group",
"pk": 2,
"fields": {
"name": "CST"
}
},
{
"model": "auth.user",
"pk": 3,
"fields": {
"password": "pbkdf2_sha256$870000$5pS1ll33O6bi2rCCELW8kZ$OvFJJIERCEE0H2RhI8WzKTi+tFhbrfo/sxFdwAUzESI=",
"last_login": null,
"is_superuser": false,
"username": "cst-user",
"first_name": "CST",
"last_name": "User",
"email": "[email protected]",
"is_staff": true,
"is_active": true,
"date_joined": "2024-09-17T18:54:46Z",
"groups": [2],
"user_permissions": []
}
}
]
3 changes: 3 additions & 0 deletions benefits/core/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,9 @@ class TransitProcessor(models.Model):
help_text="The function from the card tokenization library to call on the client to initiate the process."
)
card_tokenize_env = models.TextField(help_text="The environment in which card tokenization is occurring.")
portal_url = models.TextField(
null=True, blank=True, help_text="The absolute base URL for the TransitProcessor's control portal, including https://."
)

def __str__(self):
return self.name
Expand Down
11 changes: 11 additions & 0 deletions benefits/templates/admin/agency-dashboard-index.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,17 @@ <h2 class="pt-0 pb-2 text-left">In-person enrollment</h2>
</div>
</div>
</div>
{% if transit_processor_portal_url %}
<div class="border border-3 p-3 mt-4">
<h2 class="pt-0 pb-2 text-left">Transit Processor</h2>
<p>Manage fare-calculation, view rider transactions, and process refunds.</p>
<div class="row pt-4">
<div class="col-lg-3">
<a href="{{ transit_processor_portal_url }}" target="_blank" rel="noopener noreferrer" class="btn btn-lg btn-outline-primary">Launch Littlepay Control Portal</a>
</div>
</div>
</div>
{% endif %}
{% endif %}
</div>
</div>
Expand Down
Loading