Skip to content

Commit

Permalink
chore(models): reorder agency fields, add help_text for admin
Browse files Browse the repository at this point in the history
  • Loading branch information
thekaveman committed Aug 6, 2024
1 parent 2dd46a7 commit 98e9d1a
Show file tree
Hide file tree
Showing 3 changed files with 104 additions and 27 deletions.
75 changes: 75 additions & 0 deletions benefits/core/migrations/0019_refactor_transitagency.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Generated by Django 5.0.7 on 2024-08-06 19:14

import django.db.models.deletion
from django.db import migrations, models


Expand All @@ -16,4 +17,78 @@ class Migration(migrations.Migration):
),
migrations.RenameField(model_name="transitagency", old_name="private_key", new_name="eligibility_api_private_key"),
migrations.RenameField(model_name="transitagency", old_name="public_key", new_name="eligibility_api_public_key"),
migrations.AlterField(
model_name="transitagency",
name="active",
field=models.BooleanField(default=False, help_text="Determines if this Agency is enabled for users"),
),
migrations.AlterField(
model_name="transitagency",
name="eligibility_api_id",
field=models.TextField(help_text="The identifier for this agency used in Eligibility API calls."),
),
migrations.AlterField(
model_name="transitagency",
name="eligibility_api_jws_signing_alg",
field=models.TextField(help_text="The JWS-compatible signing algorithm used in Eligibility API calls."),
),
migrations.AlterField(
model_name="transitagency",
name="eligibility_api_private_key",
field=models.ForeignKey(
help_text="Private key used to sign Eligibility API tokens created on behalf of this Agency.",
on_delete=django.db.models.deletion.PROTECT,
related_name="+",
to="core.pemdata",
),
),
migrations.AlterField(
model_name="transitagency",
name="eligibility_api_public_key",
field=models.ForeignKey(
help_text="Public key corresponding to the agency's private key, used by Eligibility Verification servers to encrypt responses.", # noqa: E501
on_delete=django.db.models.deletion.PROTECT,
related_name="+",
to="core.pemdata",
),
),
migrations.AlterField(
model_name="transitagency",
name="eligibility_index_template",
field=models.TextField(help_text="The template used for this agency's eligibility landing page"),
),
migrations.AlterField(
model_name="transitagency",
name="index_template",
field=models.TextField(help_text="The template used for this agency's landing page"),
),
migrations.AlterField(
model_name="transitagency",
name="info_url",
field=models.URLField(help_text="URL of a website/page with more information about the agency's discounts"),
),
migrations.AlterField(
model_name="transitagency",
name="long_name",
field=models.TextField(
help_text="The user-facing long name for this agency. Often the short_name acronym, spelled out."
),
),
migrations.AlterField(
model_name="transitagency",
name="phone",
field=models.TextField(help_text="Agency customer support phone number"),
),
migrations.AlterField(
model_name="transitagency",
name="short_name",
field=models.TextField(help_text="The user-facing short name for this agency. Often an uppercase acronym."),
),
migrations.AlterField(
model_name="transitagency",
name="slug",
field=models.TextField(
help_text="Used for URL navigation for this agency, e.g. the agency homepage url is /{slug}"
),
),
]
18 changes: 9 additions & 9 deletions benefits/core/migrations/local_fixtures.json
Original file line number Diff line number Diff line change
Expand Up @@ -190,24 +190,24 @@
"model": "core.transitagency",
"pk": 1,
"fields": {
"active": true,
"eligibility_types": [1, 2, 3, 4],
"eligibility_verifiers": [1, 2, 3, 4],
"slug": "cst",
"short_name": "CST (local)",
"long_name": "California State Transit (local)",
"info_url": "https://www.agency-website.com",
"phone": "1-800-555-5555",
"active": true,
"transit_processor": 1,
"transit_processor_client_id": "",
"transit_processor_client_secret_name": "cst-transit-processor-client-secret",
"transit_processor_audience": "",
"index_template": "core/index--cst.html",
"eligibility_index_template": "eligibility/index--cst.html",
"eligibility_api_id": "cst",
"eligibility_api_private_key": 2,
"eligibility_api_public_key": 3,
"eligibility_api_jws_signing_alg": "RS256",
"index_template": "core/index--cst.html",
"eligibility_index_template": "eligibility/index--cst.html",
"eligibility_types": [1, 2, 3, 4],
"eligibility_verifiers": [1, 2, 3, 4]
"transit_processor": 1,
"transit_processor_audience": "",
"transit_processor_client_id": "",
"transit_processor_client_secret_name": "cst-transit-processor-client-secret"
}
}
]
38 changes: 20 additions & 18 deletions benefits/core/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -258,25 +258,18 @@ class TransitAgency(models.Model):
"""An agency offering transit service."""

id = models.AutoField(primary_key=True)
slug = models.TextField()
short_name = models.TextField()
long_name = models.TextField()
info_url = models.URLField()
phone = models.TextField()
active = models.BooleanField(default=False)
active = models.BooleanField(default=False, help_text="Determines if this Agency is enabled for users")
eligibility_types = models.ManyToManyField(EligibilityType)
eligibility_verifiers = models.ManyToManyField(EligibilityVerifier)
transit_processor = models.ForeignKey(TransitProcessor, on_delete=models.PROTECT)
transit_processor_client_id = models.TextField(
help_text="This agency's client_id value used to access the TransitProcessor's API.", default=""
)
transit_processor_client_secret_name = SecretNameField(
help_text="The name of the secret containing this agency's client_secret value used to access the TransitProcessor's API.", # noqa: E501
default="",
)
transit_processor_audience = models.TextField(
help_text="This agency's audience value used to access the TransitProcessor's API.", default=""
slug = models.TextField(help_text="Used for URL navigation for this agency, e.g. the agency homepage url is /{slug}")
short_name = models.TextField(help_text="The user-facing short name for this agency. Often an uppercase acronym.")
long_name = models.TextField(
help_text="The user-facing long name for this agency. Often the short_name acronym, spelled out."
)
info_url = models.URLField(help_text="URL of a website/page with more information about the agency's discounts")
phone = models.TextField(help_text="Agency customer support phone number")
index_template = models.TextField(help_text="The template used for this agency's landing page")
eligibility_index_template = models.TextField(help_text="The template used for this agency's eligibility landing page")
eligibility_api_id = models.TextField(help_text="The identifier for this agency used in Eligibility API calls.")
eligibility_api_private_key = models.ForeignKey(
PemData,
Expand All @@ -293,8 +286,17 @@ class TransitAgency(models.Model):
eligibility_api_jws_signing_alg = models.TextField(
help_text="The JWS-compatible signing algorithm used in Eligibility API calls."
)
index_template = models.TextField()
eligibility_index_template = models.TextField()
transit_processor = models.ForeignKey(TransitProcessor, on_delete=models.PROTECT)
transit_processor_audience = models.TextField(
help_text="This agency's audience value used to access the TransitProcessor's API.", default=""
)
transit_processor_client_id = models.TextField(
help_text="This agency's client_id value used to access the TransitProcessor's API.", default=""
)
transit_processor_client_secret_name = SecretNameField(
help_text="The name of the secret containing this agency's client_secret value used to access the TransitProcessor's API.", # noqa: E501
default="",
)

def __str__(self):
return self.long_name
Expand Down

0 comments on commit 98e9d1a

Please sign in to comment.