From ae65a3b2e400d78b5ca55148da71a9fecd09e836 Mon Sep 17 00:00:00 2001 From: Troy Sankey Date: Wed, 24 Jun 2026 10:48:24 -0700 Subject: [PATCH] fix: make `active` and `retired` fields clearer (SubsidyAccessPolicy) --- ...idyaccesspolicy_active_retired_helptext.py | 33 +++++++++++++++++++ .../apps/subsidy_access_policy/models.py | 24 +++++++------- 2 files changed, 45 insertions(+), 12 deletions(-) create mode 100644 enterprise_access/apps/subsidy_access_policy/migrations/0031_fix_subsidyaccesspolicy_active_retired_helptext.py diff --git a/enterprise_access/apps/subsidy_access_policy/migrations/0031_fix_subsidyaccesspolicy_active_retired_helptext.py b/enterprise_access/apps/subsidy_access_policy/migrations/0031_fix_subsidyaccesspolicy_active_retired_helptext.py new file mode 100644 index 00000000..a3e271e0 --- /dev/null +++ b/enterprise_access/apps/subsidy_access_policy/migrations/0031_fix_subsidyaccesspolicy_active_retired_helptext.py @@ -0,0 +1,33 @@ +# Generated by Django 5.2.12 on 2026-06-24 18:33 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('subsidy_access_policy', '0030_mariadb_uuid_conversion'), + ] + + operations = [ + migrations.AlterField( + model_name='historicalsubsidyaccesspolicy', + name='active', + field=models.BooleanField(default=False, help_text='Set to FALSE to deactivate this policy, and hide it from both admins and learners. Use this when you want to effectively soft-delete this policy. A typical use case is that the policy was created on accident or as a test. Caveat: you cannot deactivate a policy with existing spend/enrollments.'), + ), + migrations.AlterField( + model_name='historicalsubsidyaccesspolicy', + name='retired', + field=models.BooleanField(default=False, help_text="Set to TRUE to deactivate this policy, but NOT hide it from admins. Use this when you want to disable redemption, but you can't set active=False because this policy already has spend/enrollments."), + ), + migrations.AlterField( + model_name='subsidyaccesspolicy', + name='active', + field=models.BooleanField(default=False, help_text='Set to FALSE to deactivate this policy, and hide it from both admins and learners. Use this when you want to effectively soft-delete this policy. A typical use case is that the policy was created on accident or as a test. Caveat: you cannot deactivate a policy with existing spend/enrollments.'), + ), + migrations.AlterField( + model_name='subsidyaccesspolicy', + name='retired', + field=models.BooleanField(default=False, help_text="Set to TRUE to deactivate this policy, but NOT hide it from admins. Use this when you want to disable redemption, but you can't set active=False because this policy already has spend/enrollments."), + ), + ] diff --git a/enterprise_access/apps/subsidy_access_policy/models.py b/enterprise_access/apps/subsidy_access_policy/models.py index fc1a4365..29afc633 100644 --- a/enterprise_access/apps/subsidy_access_policy/models.py +++ b/enterprise_access/apps/subsidy_access_policy/models.py @@ -181,23 +181,16 @@ class Meta: active = models.BooleanField( default=False, help_text=( - 'Set to FALSE to deactivate and hide this policy. Use this when you want to disable redemption and make ' - 'it disappear from all frontends, effectively soft-deleting it. Default is False (deactivated).' + 'Set to FALSE to deactivate this policy, and hide it from both admins and learners. Use this when you ' + 'want to effectively soft-delete this policy. A typical use case is that the policy was created on ' + 'accident or as a test. Caveat: you cannot deactivate a policy with existing spend/enrollments.' ), ) - learner_credit_request_config = models.OneToOneField( - 'subsidy_request.LearnerCreditRequestConfiguration', - related_name="learner_credit_config", - on_delete=models.SET_NULL, - null=True, - blank=True, - ) retired = models.BooleanField( default=False, help_text=( - "True means redeemability of content using this policy has been enabled. " - "Set this to False to deactivate the policy but keep it visible from an admin's perspective " - "(useful when you want to just expire a policy without expiring the whole plan)." + "Set to TRUE to deactivate this policy, but NOT hide it from admins. Use this when you want to disable " + "redemption, but you can't set active=False because this policy already has spend/enrollments." ), ) retired_at = models.DateTimeField( @@ -207,6 +200,13 @@ class Meta: "The date and time when this policy is considered retired." ) ) + learner_credit_request_config = models.OneToOneField( + 'subsidy_request.LearnerCreditRequestConfiguration', + related_name="learner_credit_config", + on_delete=models.SET_NULL, + null=True, + blank=True, + ) catalog_uuid = models.UUIDField( db_index=True, help_text='The primary identifier of the catalog associated with this policy.',