From fce28f5d1c973ca884841fc82bc7f1da06a4b409 Mon Sep 17 00:00:00 2001 From: Kegan Maher Date: Tue, 6 Aug 2024 21:20:39 +0000 Subject: [PATCH] chore(models): reorder agency fields, add help_text for admin --- .../migrations/0019_refactor_transitagency.py | 44 +++++++++++++++++++ benefits/core/migrations/local_fixtures.json | 18 ++++---- benefits/core/models.py | 38 ++++++++-------- 3 files changed, 73 insertions(+), 27 deletions(-) diff --git a/benefits/core/migrations/0019_refactor_transitagency.py b/benefits/core/migrations/0019_refactor_transitagency.py index feac9a1a2..6a359a995 100644 --- a/benefits/core/migrations/0019_refactor_transitagency.py +++ b/benefits/core/migrations/0019_refactor_transitagency.py @@ -17,6 +17,11 @@ 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", @@ -47,4 +52,43 @@ class Migration(migrations.Migration): 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}" + ), + ), ] diff --git a/benefits/core/migrations/local_fixtures.json b/benefits/core/migrations/local_fixtures.json index cc94e1285..b7746e39c 100644 --- a/benefits/core/migrations/local_fixtures.json +++ b/benefits/core/migrations/local_fixtures.json @@ -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" } } ] diff --git a/benefits/core/models.py b/benefits/core/models.py index 180f1299d..40d9f250b 100644 --- a/benefits/core/models.py +++ b/benefits/core/models.py @@ -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, @@ -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