From e00240c73e8f4432cb78b2fbb9644891de71873d Mon Sep 17 00:00:00 2001 From: Angela Tran Date: Fri, 16 Aug 2024 16:32:59 +0000 Subject: [PATCH] feat(model): add group field to TransitAgency this allows us to link a user in the admin interface to a TransitAgency --- .../migrations/0022_transitagency_group.py | 27 +++++++++++++++++++ benefits/core/models.py | 9 +++++++ 2 files changed, 36 insertions(+) create mode 100644 benefits/core/migrations/0022_transitagency_group.py diff --git a/benefits/core/migrations/0022_transitagency_group.py b/benefits/core/migrations/0022_transitagency_group.py new file mode 100644 index 0000000000..9bbecb5d1d --- /dev/null +++ b/benefits/core/migrations/0022_transitagency_group.py @@ -0,0 +1,27 @@ +# Generated by Django 5.0.7 on 2024-08-16 16:08 + +import django.db.models.deletion +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ("auth", "0012_alter_user_first_name_max_length"), + ("core", "0021_rename_eligibilityverifier_enrollmentflow"), + ] + + operations = [ + migrations.AddField( + model_name="transitagency", + name="group", + field=models.OneToOneField( + blank=True, + default=None, + help_text="The group of users who can access this TransitAgency.", + null=True, + on_delete=django.db.models.deletion.PROTECT, + to="auth.group", + ), + ), + ] diff --git a/benefits/core/models.py b/benefits/core/models.py index ff1b3543d9..68e289b8b4 100644 --- a/benefits/core/models.py +++ b/benefits/core/models.py @@ -8,6 +8,7 @@ from django.conf import settings from django.core.exceptions import ValidationError +from django.contrib.auth.models import Group from django.db import models from django.urls import reverse @@ -352,6 +353,14 @@ class TransitAgency(models.Model): help_text="The name of the secret containing this agency's client_secret value used to access the TransitProcessor's API.", # noqa: E501 default="", ) + group = models.OneToOneField( + Group, + on_delete=models.PROTECT, + null=True, + blank=True, + default=None, + help_text="The group of users who can access this TransitAgency.", + ) def __str__(self): return self.long_name