diff --git a/benefits/core/migrations/0031_transitagency_enrollmentflow_optionalfields.py b/benefits/core/migrations/0031_transitagency_enrollmentflow_optionalfields.py index f7179d733f..2083b47a54 100644 --- a/benefits/core/migrations/0031_transitagency_enrollmentflow_optionalfields.py +++ b/benefits/core/migrations/0031_transitagency_enrollmentflow_optionalfields.py @@ -3,6 +3,9 @@ import django.db.models.deletion from django.db import migrations, models +import benefits.core.models +import benefits.secrets + class Migration(migrations.Migration): @@ -35,17 +38,14 @@ class Migration(migrations.Migration): model_name="transitagency", name="eligibility_api_id", field=models.TextField( - blank=True, default="", help_text="The identifier for this agency used in Eligibility API calls.", null=True + blank=True, default="", 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( - blank=True, - default="", - help_text="The JWS-compatible signing algorithm used in Eligibility API calls.", - null=True, + blank=True, default="", help_text="The JWS-compatible signing algorithm used in Eligibility API calls." ), ), migrations.AlterField( @@ -81,6 +81,80 @@ class Migration(migrations.Migration): help_text="Used for URL navigation for this agency, e.g. the agency homepage url is /{slug}" ), ), + migrations.AlterField( + model_name="transitagency", + name="info_url", + field=models.URLField( + default="https://www.agency-website.com", + 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( + default="California State Transit", + 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(default="1-800-555-5555", help_text="Agency customer support phone number"), + ), + migrations.AlterField( + model_name="transitagency", + name="short_name", + field=models.TextField( + default="CST", help_text="The user-facing short name for this agency. Often an uppercase acronym." + ), + ), + migrations.AlterField( + model_name="transitagency", + name="sso_domain", + field=models.TextField( + blank=True, + default="", + help_text="The email domain of users to automatically add to this agency's staff group upon login.", + ), + ), + migrations.AlterField( + model_name="transitagency", + name="transit_processor", + field=models.ForeignKey( + blank=True, + default=None, + help_text="This agency's TransitProcessor.", + null=True, + on_delete=django.db.models.deletion.PROTECT, + to="core.transitprocessor", + ), + ), + migrations.AlterField( + model_name="transitagency", + name="transit_processor_audience", + field=models.TextField( + blank=True, default="", help_text="This agency's audience value used to access the TransitProcessor's API." + ), + ), + migrations.AlterField( + model_name="transitagency", + name="transit_processor_client_id", + field=models.TextField( + blank=True, default="", help_text="This agency's client_id value used to access the TransitProcessor's API." + ), + ), + migrations.AlterField( + model_name="transitagency", + name="transit_processor_client_secret_name", + field=benefits.core.models.SecretNameField( + blank=True, + default="", + help_text="The name of the secret containing this agency's client_secret value used to access the TransitProcessor's API.", # noqa: E501 + max_length=127, + validators=[benefits.secrets.SecretNameValidator()], + ), + ), migrations.RenameField( model_name="enrollmentflow", old_name="eligibility_start_template", diff --git a/benefits/core/migrations/local_fixtures.json b/benefits/core/migrations/local_fixtures.json index 992e14231d..377827e2d7 100644 --- a/benefits/core/migrations/local_fixtures.json +++ b/benefits/core/migrations/local_fixtures.json @@ -56,8 +56,6 @@ "slug": "cst", "short_name": "CST (local)", "long_name": "California State Transit (local)", - "info_url": "https://www.agency-website.com", - "phone": "1-800-555-5555", "eligibility_api_id": "cst", "eligibility_api_private_key": 2, "eligibility_api_public_key": 3, diff --git a/benefits/core/models.py b/benefits/core/models.py index 0c4aaa610c..0d20bf30ac 100644 --- a/benefits/core/models.py +++ b/benefits/core/models.py @@ -132,12 +132,18 @@ class TransitAgency(models.Model): id = models.AutoField(primary_key=True) active = models.BooleanField(default=False, help_text="Determines if this Agency is enabled for users") slug = models.SlugField(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.") + short_name = models.TextField( + default="CST", 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." + default="California State Transit", + help_text="The user-facing long name for this agency. Often the short_name acronym, spelled out.", + ) + info_url = models.URLField( + default="https://www.agency-website.com", + help_text="URL of a website/page with more information about the agency's discounts", ) - 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") + phone = models.TextField(default="1-800-555-5555", help_text="Agency customer support phone number") index_template_override = models.TextField( help_text="Override the default template used for this agency's landing page", blank=True, @@ -150,7 +156,6 @@ class TransitAgency(models.Model): ) eligibility_api_id = models.TextField( help_text="The identifier for this agency used in Eligibility API calls.", - null=True, blank=True, default="", ) @@ -174,20 +179,27 @@ class TransitAgency(models.Model): ) eligibility_api_jws_signing_alg = models.TextField( help_text="The JWS-compatible signing algorithm used in Eligibility API calls.", - null=True, blank=True, default="", ) - transit_processor = models.ForeignKey(TransitProcessor, on_delete=models.PROTECT) + transit_processor = models.ForeignKey( + TransitProcessor, + on_delete=models.PROTECT, + null=True, + blank=True, + default=None, + help_text="This agency's TransitProcessor.", + ) transit_processor_audience = models.TextField( - help_text="This agency's audience value used to access the TransitProcessor's API.", default="" + help_text="This agency's audience value used to access the TransitProcessor's API.", default="", blank=True ) transit_processor_client_id = models.TextField( - help_text="This agency's client_id value used to access the TransitProcessor's API.", default="" + help_text="This agency's client_id value used to access the TransitProcessor's API.", default="", blank=True ) 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="", + blank=True, ) staff_group = models.OneToOneField( Group, @@ -199,7 +211,6 @@ class TransitAgency(models.Model): related_name="transit_agency", ) sso_domain = models.TextField( - null=True, blank=True, default="", help_text="The email domain of users to automatically add to this agency's staff group upon login.", diff --git a/tests/pytest/core/test_models.py b/tests/pytest/core/test_models.py index 8e60238911..9f86e2349d 100644 --- a/tests/pytest/core/test_models.py +++ b/tests/pytest/core/test_models.py @@ -407,8 +407,8 @@ def test_TransitAgency_template_overrides(model_TransitAgency): assert model_TransitAgency.index_template == model_TransitAgency.index_template_override assert model_TransitAgency.eligibility_index_template == model_TransitAgency.eligibility_index_template_override - model_TransitAgency.index_template_override = None - model_TransitAgency.eligibility_index_template_override = None + model_TransitAgency.index_template_override = "" + model_TransitAgency.eligibility_index_template_override = "" model_TransitAgency.save() assert model_TransitAgency.index_template == f"core/index--{model_TransitAgency.slug}.html"