diff --git a/src/registrar/migrations/0096_waffleswitch.py b/src/registrar/migrations/0096_waffleswitch.py deleted file mode 100644 index c8855a7ef..000000000 --- a/src/registrar/migrations/0096_waffleswitch.py +++ /dev/null @@ -1,55 +0,0 @@ -# Generated by Django 4.2.10 on 2024-05-24 15:15 - -from django.db import migrations, models -import django.utils.timezone - - -class Migration(migrations.Migration): - - dependencies = [ - ("registrar", "0095_user_middle_name_user_title"), - ] - - operations = [ - migrations.CreateModel( - name="WaffleSwitch", - fields=[ - ("id", models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name="ID")), - ( - "name", - models.CharField( - help_text="The human/computer readable name.", max_length=100, unique=True, verbose_name="Name" - ), - ), - ( - "active", - models.BooleanField(default=False, help_text="Is this switch active?", verbose_name="Active"), - ), - ( - "note", - models.TextField(blank=True, help_text="Note where this Switch is used.", verbose_name="Note"), - ), - ( - "created", - models.DateTimeField( - db_index=True, - default=django.utils.timezone.now, - help_text="Date when this Switch was created.", - verbose_name="Created", - ), - ), - ( - "modified", - models.DateTimeField( - default=django.utils.timezone.now, - help_text="Date when this Switch was last modified.", - verbose_name="Modified", - ), - ), - ], - options={ - "verbose_name": "waffle switch", - "verbose_name_plural": "Waffle switches", - }, - ), - ] diff --git a/src/registrar/migrations/0097_create_groups_v13.py b/src/registrar/migrations/0097_create_groups_v13.py deleted file mode 100644 index 90d1cb02e..000000000 --- a/src/registrar/migrations/0097_create_groups_v13.py +++ /dev/null @@ -1,37 +0,0 @@ -# This migration creates the create_full_access_group and create_cisa_analyst_group groups -# It is dependent on 0079 (which populates federal agencies) -# If permissions on the groups need changing, edit CISA_ANALYST_GROUP_PERMISSIONS -# in the user_group model then: -# [NOT RECOMMENDED] -# step 1: docker-compose exec app ./manage.py migrate --fake registrar 0035_contenttypes_permissions -# step 2: docker-compose exec app ./manage.py migrate registrar 0036_create_groups -# step 3: fake run the latest migration in the migrations list -# [RECOMMENDED] -# Alternatively: -# step 1: duplicate the migration that loads data -# step 2: docker-compose exec app ./manage.py migrate - -from django.db import migrations -from registrar.models import UserGroup -from typing import Any - - -# For linting: RunPython expects a function reference, -# so let's give it one -def create_groups(apps, schema_editor) -> Any: - UserGroup.create_cisa_analyst_group(apps, schema_editor) - UserGroup.create_full_access_group(apps, schema_editor) - - -class Migration(migrations.Migration): - dependencies = [ - ("registrar", "0096_waffleswitch"), - ] - - operations = [ - migrations.RunPython( - create_groups, - reverse_code=migrations.RunPython.noop, - atomic=True, - ), - ] diff --git a/src/registrar/models/__init__.py b/src/registrar/models/__init__.py index eda80b0ae..f084a5d8b 100644 --- a/src/registrar/models/__init__.py +++ b/src/registrar/models/__init__.py @@ -16,7 +16,6 @@ from .website import Website from .transition_domain import TransitionDomain from .verified_by_staff import VerifiedByStaff from .waffle_flag import WaffleFlag -from .waffle_switch import WaffleSwitch __all__ = [ @@ -37,7 +36,6 @@ __all__ = [ "TransitionDomain", "VerifiedByStaff", "WaffleFlag", - "WaffleSwitch", ] auditlog.register(Contact) @@ -57,4 +55,3 @@ auditlog.register(Website) auditlog.register(TransitionDomain) auditlog.register(VerifiedByStaff) auditlog.register(WaffleFlag) -auditlog.register(WaffleSwitch) diff --git a/src/registrar/models/waffle_switch.py b/src/registrar/models/waffle_switch.py deleted file mode 100644 index 7fc117342..000000000 --- a/src/registrar/models/waffle_switch.py +++ /dev/null @@ -1,18 +0,0 @@ -from waffle.models import AbstractBaseSwitch -import logging - -logger = logging.getLogger(__name__) - - -class WaffleSwitch(AbstractBaseSwitch): - """ - Custom implementation of django-waffles 'switch' object. - Read more here: https://waffle.readthedocs.io/en/stable/types/switch.html - Use this class when dealing with switches. - """ - - class Meta: - """Contains meta information about this class""" - - verbose_name = "waffle switch" - verbose_name_plural = "Waffle switches" diff --git a/src/registrar/tests/test_emails.py b/src/registrar/tests/test_emails.py index a63a0c824..831852d82 100644 --- a/src/registrar/tests/test_emails.py +++ b/src/registrar/tests/test_emails.py @@ -3,7 +3,7 @@ from unittest.mock import MagicMock from django.test import TestCase -from waffle.testutils import override_switch +from waffle.testutils import override_flag from registrar.utility import email from registrar.utility.email import send_templated_email from .common import completed_domain_request, less_console_noise @@ -18,7 +18,7 @@ class TestEmails(TestCase): self.mock_client = self.mock_client_class.return_value @boto3_mocking.patching - @override_switch("disable_email_sending", active=True) + @override_flag("disable_email_sending", active=True) def test_disable_email_switch(self): """Test if the 'disable_email_sending' stops emails from being sent """ with boto3_mocking.clients.handler_for("sesv2", self.mock_client_class): diff --git a/src/registrar/utility/email.py b/src/registrar/utility/email.py index ed121114a..40ca2186e 100644 --- a/src/registrar/utility/email.py +++ b/src/registrar/utility/email.py @@ -8,7 +8,7 @@ from django.template.loader import get_template from email.mime.application import MIMEApplication from email.mime.multipart import MIMEMultipart from email.mime.text import MIMEText -from waffle import switch_is_active +from waffle import flag_is_active logger = logging.getLogger(__name__) @@ -36,7 +36,8 @@ def send_templated_email( Raises EmailSendingError if SES client could not be accessed """ - if switch_is_active("disable_email_sending") and not settings.IS_PRODUCTION: + + if flag_is_active(None, "disable_email_sending") and not settings.IS_PRODUCTION: message = "Could not send email. Email sending is disabled due to switch 'disable_email_sending'." raise EmailSendingError(message)