From c73ab11e19315f1d24c435bd08b2844c1456ee8c Mon Sep 17 00:00:00 2001 From: Christinarlong Date: Fri, 15 Nov 2024 09:57:13 -0800 Subject: [PATCH 1/3] move over notificationsettingoption --- .../user_notification_settings_options.py | 2 +- ...er_notification_settings_options_detail.py | 2 +- src/sentry/models/__init__.py | 1 - .../models/notificationsettingoption.py | 41 +------------------ .../models/notificationsettingoption.py | 40 ++++++++++++++++++ .../notifications/notificationcontroller.py | 2 +- src/sentry/notifications/serializers.py | 2 +- src/sentry/notifications/services/impl.py | 2 +- src/sentry/testutils/cases.py | 2 +- .../test_organization_unsubscribe.py | 2 +- ...test_user_notification_settings_options.py | 2 +- ...r_notification_settings_options_details.py | 2 +- tests/sentry/api/serializers/test_group.py | 2 +- tests/sentry/db/models/test_base.py | 2 +- .../incidents/action_handlers/test_email.py | 2 +- .../slack/notifications/test_issue_alert.py | 2 +- tests/sentry/mail/activity/test_note.py | 2 +- tests/sentry/mail/activity/test_release.py | 2 +- tests/sentry/mail/test_adapter.py | 2 +- ...st_0574_bacfkill_weekly_report_settings.py | 2 +- ...ken_monitor_notification_setting_option.py | 2 +- tests/sentry/models/test_groupsubscription.py | 2 +- tests/sentry/models/test_organization.py | 2 +- tests/sentry/models/test_project.py | 2 +- tests/sentry/models/test_team.py | 2 +- .../tasks/test_detect_broken_monitor_envs.py | 2 +- .../models/test_notificationsettingoption.py | 2 +- tests/sentry/notifications/test_helpers.py | 2 +- .../test_notificationcontroller.py | 2 +- .../notifications/test_notifications.py | 2 +- .../notifications/utils/test_participants.py | 2 +- tests/sentry/tasks/test_weekly_reports.py | 2 +- tests/snuba/api/serializers/test_group.py | 2 +- 33 files changed, 72 insertions(+), 70 deletions(-) create mode 100644 src/sentry/notifications/models/notificationsettingoption.py rename tests/sentry/{ => notifications}/models/test_notificationsettingoption.py (96%) diff --git a/src/sentry/api/endpoints/user_notification_settings_options.py b/src/sentry/api/endpoints/user_notification_settings_options.py index a381d1eee7858..c72a7b778c23a 100644 --- a/src/sentry/api/endpoints/user_notification_settings_options.py +++ b/src/sentry/api/endpoints/user_notification_settings_options.py @@ -8,7 +8,7 @@ from sentry.api.exceptions import ParameterValidationError from sentry.api.serializers import serialize from sentry.api.validators.notifications import validate_type -from sentry.models.notificationsettingoption import NotificationSettingOption +from sentry.notifications.models.notificationsettingoption import NotificationSettingOption from sentry.notifications.serializers import NotificationSettingsOptionSerializer from sentry.notifications.validators import UserNotificationSettingOptionWithValueSerializer from sentry.users.api.bases.user import UserEndpoint diff --git a/src/sentry/api/endpoints/user_notification_settings_options_detail.py b/src/sentry/api/endpoints/user_notification_settings_options_detail.py index 53e73e039e850..e7f46bcca4207 100644 --- a/src/sentry/api/endpoints/user_notification_settings_options_detail.py +++ b/src/sentry/api/endpoints/user_notification_settings_options_detail.py @@ -6,7 +6,7 @@ from sentry.api.api_owners import ApiOwner from sentry.api.api_publish_status import ApiPublishStatus from sentry.api.base import control_silo_endpoint -from sentry.models.notificationsettingoption import NotificationSettingOption +from sentry.notifications.models.notificationsettingoption import NotificationSettingOption from sentry.users.api.bases.user import UserEndpoint from sentry.users.models.user import User diff --git a/src/sentry/models/__init__.py b/src/sentry/models/__init__.py index 1a18f4dc34799..0345b595c37f3 100644 --- a/src/sentry/models/__init__.py +++ b/src/sentry/models/__init__.py @@ -61,7 +61,6 @@ from .importchunk import * # NOQA from .latestreporeleaseenvironment import * # NOQA from .notificationmessage import * # NOQA -from .notificationsettingoption import * # NOQA from .notificationsettingprovider import * # NOQA from .options import * # NOQA from .organization import * # NOQA diff --git a/src/sentry/models/notificationsettingoption.py b/src/sentry/models/notificationsettingoption.py index 4cf7964482120..af3d50ab806ef 100644 --- a/src/sentry/models/notificationsettingoption.py +++ b/src/sentry/models/notificationsettingoption.py @@ -1,40 +1,3 @@ -from django.db import models +from sentry.notifications.models.notificationsettingoption import NotificationSettingOption -from sentry.backup.scopes import RelocationScope -from sentry.db.models import control_silo_model, sane_repr - -from .notificationsettingbase import NotificationSettingBase - - -@control_silo_model -class NotificationSettingOption(NotificationSettingBase): - __relocation_scope__ = RelocationScope.Excluded - - class Meta: - app_label = "sentry" - db_table = "sentry_notificationsettingoption" - unique_together = ( - ( - "scope_type", - "scope_identifier", - "user_id", - "team_id", - "type", - ), - ) - constraints = [ - models.CheckConstraint( - condition=models.Q(team_id__isnull=False, user_id__isnull=True) - | models.Q(team_id__isnull=True, user_id__isnull=False), - name="notification_setting_option_team_or_user_check", - ) - ] - - __repr__ = sane_repr( - "scope_type", - "scope_identifier", - "type", - "user_id", - "team_id", - "value", - ) +__all__ = ("NotificationSettingOption",) diff --git a/src/sentry/notifications/models/notificationsettingoption.py b/src/sentry/notifications/models/notificationsettingoption.py new file mode 100644 index 0000000000000..ee488ab6d3aac --- /dev/null +++ b/src/sentry/notifications/models/notificationsettingoption.py @@ -0,0 +1,40 @@ +from django.db import models + +from sentry.backup.scopes import RelocationScope +from sentry.db.models import control_silo_model, sane_repr + +from ...models.notificationsettingbase import NotificationSettingBase + + +@control_silo_model +class NotificationSettingOption(NotificationSettingBase): + __relocation_scope__ = RelocationScope.Excluded + + class Meta: + app_label = "sentry" + db_table = "sentry_notificationsettingoption" + unique_together = ( + ( + "scope_type", + "scope_identifier", + "user_id", + "team_id", + "type", + ), + ) + constraints = [ + models.CheckConstraint( + condition=models.Q(team_id__isnull=False, user_id__isnull=True) + | models.Q(team_id__isnull=True, user_id__isnull=False), + name="notification_setting_option_team_or_user_check", + ) + ] + + __repr__ = sane_repr( + "scope_type", + "scope_identifier", + "type", + "user_id", + "team_id", + "value", + ) diff --git a/src/sentry/notifications/notificationcontroller.py b/src/sentry/notifications/notificationcontroller.py index 9909452ea613f..0d1c83e86de3f 100644 --- a/src/sentry/notifications/notificationcontroller.py +++ b/src/sentry/notifications/notificationcontroller.py @@ -14,7 +14,6 @@ ExternalProviderEnum, ExternalProviders, ) -from sentry.models.notificationsettingoption import NotificationSettingOption from sentry.models.notificationsettingprovider import NotificationSettingProvider from sentry.models.organizationmapping import OrganizationMapping from sentry.models.team import Team @@ -26,6 +25,7 @@ recipient_is_user, team_is_valid_recipient, ) +from sentry.notifications.models.notificationsettingoption import NotificationSettingOption from sentry.notifications.types import ( GroupSubscriptionStatus, NotificationScopeEnum, diff --git a/src/sentry/notifications/serializers.py b/src/sentry/notifications/serializers.py index f4ef2f4144698..40a241943aee9 100644 --- a/src/sentry/notifications/serializers.py +++ b/src/sentry/notifications/serializers.py @@ -4,8 +4,8 @@ from typing import Any from sentry.api.serializers import Serializer -from sentry.models.notificationsettingoption import NotificationSettingOption from sentry.models.notificationsettingprovider import NotificationSettingProvider +from sentry.notifications.models.notificationsettingoption import NotificationSettingOption class NotificationSettingsBaseSerializer(Serializer): diff --git a/src/sentry/notifications/services/impl.py b/src/sentry/notifications/services/impl.py index 9740cc34aa589..aa07f1853e2fa 100644 --- a/src/sentry/notifications/services/impl.py +++ b/src/sentry/notifications/services/impl.py @@ -5,8 +5,8 @@ from django.db import router, transaction from sentry.integrations.types import EXTERNAL_PROVIDERS, ExternalProviderEnum, ExternalProviders -from sentry.models.notificationsettingoption import NotificationSettingOption from sentry.models.notificationsettingprovider import NotificationSettingProvider +from sentry.notifications.models.notificationsettingoption import NotificationSettingOption from sentry.notifications.notificationcontroller import NotificationController from sentry.notifications.services import NotificationsService from sentry.notifications.services.model import RpcSubscriptionStatus diff --git a/src/sentry/testutils/cases.py b/src/sentry/testutils/cases.py index 9275f344ad0f0..6a9e32fa7ac0d 100644 --- a/src/sentry/testutils/cases.py +++ b/src/sentry/testutils/cases.py @@ -99,7 +99,6 @@ from sentry.models.environment import Environment from sentry.models.files.file import File from sentry.models.groupmeta import GroupMeta -from sentry.models.notificationsettingoption import NotificationSettingOption from sentry.models.notificationsettingprovider import NotificationSettingProvider from sentry.models.options.project_option import ProjectOption from sentry.models.organization import Organization @@ -110,6 +109,7 @@ from sentry.models.repository import Repository from sentry.models.rule import RuleSource from sentry.monitors.models import Monitor, MonitorEnvironment, MonitorType, ScheduleType +from sentry.notifications.models.notificationsettingoption import NotificationSettingOption from sentry.notifications.notifications.base import alert_page_needs_org_id from sentry.notifications.types import FineTuningAPIKey from sentry.organizations.services.organization.serial import serialize_rpc_organization diff --git a/tests/sentry/api/endpoints/test_organization_unsubscribe.py b/tests/sentry/api/endpoints/test_organization_unsubscribe.py index ff17b8414e7e4..3714487a7cf22 100644 --- a/tests/sentry/api/endpoints/test_organization_unsubscribe.py +++ b/tests/sentry/api/endpoints/test_organization_unsubscribe.py @@ -1,7 +1,7 @@ from django.urls import reverse from sentry.models.groupsubscription import GroupSubscription -from sentry.models.notificationsettingoption import NotificationSettingOption +from sentry.notifications.models.notificationsettingoption import NotificationSettingOption from sentry.silo.base import SiloMode from sentry.testutils.cases import APITestCase from sentry.testutils.silo import assume_test_silo_mode diff --git a/tests/sentry/api/endpoints/test_user_notification_settings_options.py b/tests/sentry/api/endpoints/test_user_notification_settings_options.py index dc29e872c174f..97344553d10fe 100644 --- a/tests/sentry/api/endpoints/test_user_notification_settings_options.py +++ b/tests/sentry/api/endpoints/test_user_notification_settings_options.py @@ -1,6 +1,6 @@ from rest_framework import status -from sentry.models.notificationsettingoption import NotificationSettingOption +from sentry.notifications.models.notificationsettingoption import NotificationSettingOption from sentry.notifications.types import ( NotificationScopeEnum, NotificationSettingEnum, diff --git a/tests/sentry/api/endpoints/test_user_notification_settings_options_details.py b/tests/sentry/api/endpoints/test_user_notification_settings_options_details.py index ff9dc10158df1..1ad3989b9b81e 100644 --- a/tests/sentry/api/endpoints/test_user_notification_settings_options_details.py +++ b/tests/sentry/api/endpoints/test_user_notification_settings_options_details.py @@ -1,6 +1,6 @@ from rest_framework import status -from sentry.models.notificationsettingoption import NotificationSettingOption +from sentry.notifications.models.notificationsettingoption import NotificationSettingOption from sentry.notifications.types import ( NotificationScopeEnum, NotificationSettingEnum, diff --git a/tests/sentry/api/serializers/test_group.py b/tests/sentry/api/serializers/test_group.py index 7a9d62441bde5..30ee5e14249ea 100644 --- a/tests/sentry/api/serializers/test_group.py +++ b/tests/sentry/api/serializers/test_group.py @@ -10,8 +10,8 @@ from sentry.models.groupresolution import GroupResolution from sentry.models.groupsnooze import GroupSnooze from sentry.models.groupsubscription import GroupSubscription -from sentry.models.notificationsettingoption import NotificationSettingOption from sentry.models.notificationsettingprovider import NotificationSettingProvider +from sentry.notifications.models.notificationsettingoption import NotificationSettingOption from sentry.notifications.types import ( NotificationScopeEnum, NotificationSettingEnum, diff --git a/tests/sentry/db/models/test_base.py b/tests/sentry/db/models/test_base.py index f2057752424e5..9eb691e11b4d4 100644 --- a/tests/sentry/db/models/test_base.py +++ b/tests/sentry/db/models/test_base.py @@ -11,7 +11,6 @@ RegionImportChunk, ) from sentry.models.notificationsettingbase import NotificationSettingBase -from sentry.models.notificationsettingoption import NotificationSettingOption from sentry.models.notificationsettingprovider import NotificationSettingProvider from sentry.models.projecttemplate import ProjectTemplate from sentry.models.relocation import ( @@ -24,6 +23,7 @@ ProjectTransactionThreshold, ProjectTransactionThresholdOverride, ) +from sentry.notifications.models.notificationsettingoption import NotificationSettingOption from sentry.sentry_apps.models import SentryAppInstallationForProvider from sentry.uptime.models import ProjectUptimeSubscription, UptimeSubscription diff --git a/tests/sentry/incidents/action_handlers/test_email.py b/tests/sentry/incidents/action_handlers/test_email.py index 3bee199a0beff..e84b1f6cf20eb 100644 --- a/tests/sentry/incidents/action_handlers/test_email.py +++ b/tests/sentry/incidents/action_handlers/test_email.py @@ -26,7 +26,7 @@ ) from sentry.incidents.models.incident import INCIDENT_STATUS, IncidentStatus, TriggerStatus from sentry.incidents.utils.types import AlertRuleActivationConditionType -from sentry.models.notificationsettingoption import NotificationSettingOption +from sentry.notifications.models.notificationsettingoption import NotificationSettingOption from sentry.seer.anomaly_detection.types import StoreDataResponse from sentry.sentry_metrics import indexer from sentry.sentry_metrics.use_case_id_registry import UseCaseID diff --git a/tests/sentry/integrations/slack/notifications/test_issue_alert.py b/tests/sentry/integrations/slack/notifications/test_issue_alert.py index f72807e6eeb86..d095636bb8327 100644 --- a/tests/sentry/integrations/slack/notifications/test_issue_alert.py +++ b/tests/sentry/integrations/slack/notifications/test_issue_alert.py @@ -16,10 +16,10 @@ from sentry.integrations.types import ExternalProviders from sentry.issues.grouptype import MonitorIncidentType from sentry.issues.issue_occurrence import IssueEvidence, IssueOccurrence -from sentry.models.notificationsettingoption import NotificationSettingOption from sentry.models.notificationsettingprovider import NotificationSettingProvider from sentry.models.projectownership import ProjectOwnership from sentry.models.rule import Rule +from sentry.notifications.models.notificationsettingoption import NotificationSettingOption from sentry.notifications.notifications.rules import AlertRuleNotification from sentry.notifications.types import ActionTargetType, FallthroughChoiceType, FineTuningAPIKey from sentry.ownership.grammar import Matcher, Owner diff --git a/tests/sentry/mail/activity/test_note.py b/tests/sentry/mail/activity/test_note.py index da3d30b42dfc8..77391b5fe15d0 100644 --- a/tests/sentry/mail/activity/test_note.py +++ b/tests/sentry/mail/activity/test_note.py @@ -1,6 +1,6 @@ from sentry.integrations.types import ExternalProviders from sentry.models.activity import Activity -from sentry.models.notificationsettingoption import NotificationSettingOption +from sentry.notifications.models.notificationsettingoption import NotificationSettingOption from sentry.notifications.notifications.activity.note import NoteActivityNotification from sentry.notifications.types import GroupSubscriptionReason from sentry.silo.base import SiloMode diff --git a/tests/sentry/mail/activity/test_release.py b/tests/sentry/mail/activity/test_release.py index b33c5157cf2f8..c90640e921117 100644 --- a/tests/sentry/mail/activity/test_release.py +++ b/tests/sentry/mail/activity/test_release.py @@ -3,10 +3,10 @@ from sentry.integrations.types import ExternalProviderEnum, ExternalProviders from sentry.models.activity import Activity from sentry.models.environment import Environment -from sentry.models.notificationsettingoption import NotificationSettingOption from sentry.models.notificationsettingprovider import NotificationSettingProvider from sentry.models.release import Release from sentry.models.repository import Repository +from sentry.notifications.models.notificationsettingoption import NotificationSettingOption from sentry.notifications.notifications.activity.release import ReleaseActivityNotification from sentry.notifications.types import ( GroupSubscriptionReason, diff --git a/tests/sentry/mail/test_adapter.py b/tests/sentry/mail/test_adapter.py index d67844c3bbcd0..0e53c3e4a3da4 100644 --- a/tests/sentry/mail/test_adapter.py +++ b/tests/sentry/mail/test_adapter.py @@ -22,7 +22,6 @@ from sentry.mail import build_subject_prefix, mail_adapter from sentry.models.activity import Activity from sentry.models.grouprelease import GroupRelease -from sentry.models.notificationsettingoption import NotificationSettingOption from sentry.models.notificationsettingprovider import NotificationSettingProvider from sentry.models.options.project_option import ProjectOption from sentry.models.organization import Organization @@ -33,6 +32,7 @@ from sentry.models.repository import Repository from sentry.models.rule import Rule from sentry.models.userreport import UserReport +from sentry.notifications.models.notificationsettingoption import NotificationSettingOption from sentry.notifications.notifications.rules import AlertRuleNotification from sentry.notifications.types import ActionTargetType, FallthroughChoiceType from sentry.notifications.utils.digest import get_digest_subject diff --git a/tests/sentry/migrations/test_0574_bacfkill_weekly_report_settings.py b/tests/sentry/migrations/test_0574_bacfkill_weekly_report_settings.py index 74693f0cc8e66..f5cc89c387a2b 100644 --- a/tests/sentry/migrations/test_0574_bacfkill_weekly_report_settings.py +++ b/tests/sentry/migrations/test_0574_bacfkill_weekly_report_settings.py @@ -2,7 +2,7 @@ import pytest -from sentry.models.notificationsettingoption import NotificationSettingOption +from sentry.notifications.models.notificationsettingoption import NotificationSettingOption from sentry.testutils.cases import TestMigrations diff --git a/tests/sentry/migrations/test_0743_backfill_broken_monitor_notification_setting_option.py b/tests/sentry/migrations/test_0743_backfill_broken_monitor_notification_setting_option.py index 680cab38294a7..b60e81ad90141 100644 --- a/tests/sentry/migrations/test_0743_backfill_broken_monitor_notification_setting_option.py +++ b/tests/sentry/migrations/test_0743_backfill_broken_monitor_notification_setting_option.py @@ -2,7 +2,7 @@ import pytest -from sentry.models.notificationsettingoption import NotificationSettingOption +from sentry.notifications.models.notificationsettingoption import NotificationSettingOption from sentry.testutils.cases import TestMigrations from sentry.testutils.silo import control_silo_test diff --git a/tests/sentry/models/test_groupsubscription.py b/tests/sentry/models/test_groupsubscription.py index 93f37d27f791a..9520ea21701f8 100644 --- a/tests/sentry/models/test_groupsubscription.py +++ b/tests/sentry/models/test_groupsubscription.py @@ -3,9 +3,9 @@ from sentry.integrations.types import ExternalProviderEnum, ExternalProviders from sentry.models.group import Group from sentry.models.groupsubscription import GroupSubscription -from sentry.models.notificationsettingoption import NotificationSettingOption from sentry.models.notificationsettingprovider import NotificationSettingProvider from sentry.models.team import Team +from sentry.notifications.models.notificationsettingoption import NotificationSettingOption from sentry.notifications.types import ( GroupSubscriptionReason, NotificationScopeEnum, diff --git a/tests/sentry/models/test_organization.py b/tests/sentry/models/test_organization.py index 91045e0444be0..86ac41c6b4f45 100644 --- a/tests/sentry/models/test_organization.py +++ b/tests/sentry/models/test_organization.py @@ -19,11 +19,11 @@ ) from sentry.models.apikey import ApiKey from sentry.models.auditlogentry import AuditLogEntry -from sentry.models.notificationsettingoption import NotificationSettingOption from sentry.models.notificationsettingprovider import NotificationSettingProvider from sentry.models.options.organization_option import OrganizationOption from sentry.models.organization import Organization from sentry.models.organizationmember import OrganizationMember +from sentry.notifications.models.notificationsettingoption import NotificationSettingOption from sentry.silo.base import SiloMode from sentry.testutils.cases import TestCase from sentry.testutils.helpers.features import with_feature diff --git a/tests/sentry/models/test_project.py b/tests/sentry/models/test_project.py index 88d70b6231e49..21431776a8dd2 100644 --- a/tests/sentry/models/test_project.py +++ b/tests/sentry/models/test_project.py @@ -7,7 +7,6 @@ from sentry.integrations.types import ExternalProviders from sentry.models.environment import Environment, EnvironmentProject from sentry.models.grouplink import GroupLink -from sentry.models.notificationsettingoption import NotificationSettingOption from sentry.models.options.project_option import ProjectOption from sentry.models.options.project_template_option import ProjectTemplateOption from sentry.models.organizationmember import OrganizationMember @@ -20,6 +19,7 @@ from sentry.models.releases.release_project import ReleaseProject from sentry.models.rule import Rule from sentry.monitors.models import Monitor, MonitorEnvironment, MonitorType, ScheduleType +from sentry.notifications.models.notificationsettingoption import NotificationSettingOption from sentry.notifications.types import NotificationSettingEnum from sentry.notifications.utils.participants import get_notification_recipients from sentry.silo.base import SiloMode diff --git a/tests/sentry/models/test_team.py b/tests/sentry/models/test_team.py index f1c9401dea3be..0d166e1726de4 100644 --- a/tests/sentry/models/test_team.py +++ b/tests/sentry/models/test_team.py @@ -1,11 +1,11 @@ from django.test import override_settings from sentry.deletions.tasks.hybrid_cloud import schedule_hybrid_cloud_foreign_key_jobs_control -from sentry.models.notificationsettingoption import NotificationSettingOption from sentry.models.notificationsettingprovider import NotificationSettingProvider from sentry.models.organizationmember import OrganizationMember from sentry.models.organizationmemberteam import OrganizationMemberTeam from sentry.models.team import Team +from sentry.notifications.models.notificationsettingoption import NotificationSettingOption from sentry.silo.base import SiloMode from sentry.testutils.cases import TestCase from sentry.testutils.outbox import outbox_runner diff --git a/tests/sentry/monitors/tasks/test_detect_broken_monitor_envs.py b/tests/sentry/monitors/tasks/test_detect_broken_monitor_envs.py index c8070831e230a..d861f8c5ce875 100644 --- a/tests/sentry/monitors/tasks/test_detect_broken_monitor_envs.py +++ b/tests/sentry/monitors/tasks/test_detect_broken_monitor_envs.py @@ -6,7 +6,6 @@ from sentry.constants import ObjectStatus from sentry.grouping.utils import hash_from_values -from sentry.models.notificationsettingoption import NotificationSettingOption from sentry.monitors.models import ( CheckInStatus, Monitor, @@ -19,6 +18,7 @@ ScheduleType, ) from sentry.monitors.tasks.detect_broken_monitor_envs import detect_broken_monitor_envs +from sentry.notifications.models.notificationsettingoption import NotificationSettingOption from sentry.silo.base import SiloMode from sentry.testutils.cases import TestCase from sentry.testutils.helpers.datetime import before_now diff --git a/tests/sentry/models/test_notificationsettingoption.py b/tests/sentry/notifications/models/test_notificationsettingoption.py similarity index 96% rename from tests/sentry/models/test_notificationsettingoption.py rename to tests/sentry/notifications/models/test_notificationsettingoption.py index fe4d3f17bdd2f..e1852fa10fb81 100644 --- a/tests/sentry/models/test_notificationsettingoption.py +++ b/tests/sentry/notifications/models/test_notificationsettingoption.py @@ -1,5 +1,5 @@ from sentry.deletions.tasks.hybrid_cloud import schedule_hybrid_cloud_foreign_key_jobs_control -from sentry.models.notificationsettingoption import NotificationSettingOption +from sentry.notifications.models.notificationsettingoption import NotificationSettingOption from sentry.silo.base import SiloMode from sentry.testutils.cases import TestCase from sentry.testutils.outbox import outbox_runner diff --git a/tests/sentry/notifications/test_helpers.py b/tests/sentry/notifications/test_helpers.py index 069bc73869063..8e556abfb0aea 100644 --- a/tests/sentry/notifications/test_helpers.py +++ b/tests/sentry/notifications/test_helpers.py @@ -2,7 +2,6 @@ from urllib.parse import parse_qs, urlparse from sentry.integrations.models.external_actor import ExternalActor -from sentry.models.notificationsettingoption import NotificationSettingOption from sentry.models.organizationmemberteamreplica import OrganizationMemberTeamReplica from sentry.models.rule import Rule from sentry.notifications.helpers import ( @@ -12,6 +11,7 @@ team_is_valid_recipient, validate, ) +from sentry.notifications.models.notificationsettingoption import NotificationSettingOption from sentry.notifications.types import NotificationSettingEnum, NotificationSettingsOptionEnum from sentry.notifications.utils import ( get_email_link_extra_params, diff --git a/tests/sentry/notifications/test_notificationcontroller.py b/tests/sentry/notifications/test_notificationcontroller.py index ba887f384f7af..2e91ffbd50e6d 100644 --- a/tests/sentry/notifications/test_notificationcontroller.py +++ b/tests/sentry/notifications/test_notificationcontroller.py @@ -1,8 +1,8 @@ from sentry.integrations.models.external_actor import ExternalActor from sentry.integrations.types import ExternalProviderEnum, ExternalProviders -from sentry.models.notificationsettingoption import NotificationSettingOption from sentry.models.notificationsettingprovider import NotificationSettingProvider from sentry.models.team import Team +from sentry.notifications.models.notificationsettingoption import NotificationSettingOption from sentry.notifications.notificationcontroller import NotificationController from sentry.notifications.types import ( GroupSubscriptionStatus, diff --git a/tests/sentry/notifications/test_notifications.py b/tests/sentry/notifications/test_notifications.py index 74f481b8f7d7a..902f15941e5fe 100644 --- a/tests/sentry/notifications/test_notifications.py +++ b/tests/sentry/notifications/test_notifications.py @@ -18,8 +18,8 @@ from sentry.models.activity import Activity from sentry.models.group import Group, GroupStatus from sentry.models.groupassignee import GroupAssignee -from sentry.models.notificationsettingoption import NotificationSettingOption from sentry.models.rule import Rule +from sentry.notifications.models.notificationsettingoption import NotificationSettingOption from sentry.notifications.notifications.activity.assigned import AssignedActivityNotification from sentry.notifications.notifications.activity.regression import RegressionActivityNotification from sentry.silo.base import SiloMode diff --git a/tests/sentry/notifications/utils/test_participants.py b/tests/sentry/notifications/utils/test_participants.py index d2a7c8ebfdb5f..06638be79630a 100644 --- a/tests/sentry/notifications/utils/test_participants.py +++ b/tests/sentry/notifications/utils/test_participants.py @@ -12,12 +12,12 @@ from sentry.models.commit import Commit from sentry.models.groupassignee import GroupAssignee from sentry.models.groupowner import GroupOwner, GroupOwnerType -from sentry.models.notificationsettingoption import NotificationSettingOption from sentry.models.notificationsettingprovider import NotificationSettingProvider from sentry.models.project import Project from sentry.models.projectownership import ProjectOwnership from sentry.models.repository import Repository from sentry.models.team import Team +from sentry.notifications.models.notificationsettingoption import NotificationSettingOption from sentry.notifications.types import ( ActionTargetType, FallthroughChoiceType, diff --git a/tests/sentry/tasks/test_weekly_reports.py b/tests/sentry/tasks/test_weekly_reports.py index 15eb343d55a34..191df95f1ef13 100644 --- a/tests/sentry/tasks/test_weekly_reports.py +++ b/tests/sentry/tasks/test_weekly_reports.py @@ -14,9 +14,9 @@ from sentry.issues.grouptype import MonitorIncidentType, PerformanceNPlusOneGroupType from sentry.models.group import GroupStatus from sentry.models.grouphistory import GroupHistoryStatus -from sentry.models.notificationsettingoption import NotificationSettingOption from sentry.models.organizationmember import OrganizationMember from sentry.models.project import Project +from sentry.notifications.models.notificationsettingoption import NotificationSettingOption from sentry.silo.base import SiloMode from sentry.silo.safety import unguarded_write from sentry.snuba.referrer import Referrer diff --git a/tests/snuba/api/serializers/test_group.py b/tests/snuba/api/serializers/test_group.py index 955cf14a5bcc4..a8b2a3e96c84b 100644 --- a/tests/snuba/api/serializers/test_group.py +++ b/tests/snuba/api/serializers/test_group.py @@ -13,7 +13,7 @@ from sentry.models.groupresolution import GroupResolution from sentry.models.groupsnooze import GroupSnooze from sentry.models.groupsubscription import GroupSubscription -from sentry.models.notificationsettingoption import NotificationSettingOption +from sentry.notifications.models.notificationsettingoption import NotificationSettingOption from sentry.notifications.types import NotificationSettingsOptionEnum from sentry.silo.base import SiloMode from sentry.testutils.cases import APITestCase, PerformanceIssueTestCase, SnubaTestCase From f580dde8615fef3db4a938e024e53899b44fa153 Mon Sep 17 00:00:00 2001 From: Christinarlong Date: Fri, 15 Nov 2024 12:42:18 -0800 Subject: [PATCH 2/3] absolute imports --- src/sentry/notifications/models/notificationsettingoption.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/sentry/notifications/models/notificationsettingoption.py b/src/sentry/notifications/models/notificationsettingoption.py index ee488ab6d3aac..4d9d6d76982d9 100644 --- a/src/sentry/notifications/models/notificationsettingoption.py +++ b/src/sentry/notifications/models/notificationsettingoption.py @@ -2,8 +2,7 @@ from sentry.backup.scopes import RelocationScope from sentry.db.models import control_silo_model, sane_repr - -from ...models.notificationsettingbase import NotificationSettingBase +from sentry.models.notificationsettingbase import NotificationSettingBase @control_silo_model From a9bf09331cbdf98e02c98381a4ea6a9fc2d1ac0c Mon Sep 17 00:00:00 2001 From: Christinarlong Date: Fri, 15 Nov 2024 13:04:40 -0800 Subject: [PATCH 3/3] add barrel file for django to find models and add to installed apps --- src/sentry/conf/server.py | 1 + src/sentry/notifications/models/__init__.py | 3 +++ 2 files changed, 4 insertions(+) create mode 100644 src/sentry/notifications/models/__init__.py diff --git a/src/sentry/conf/server.py b/src/sentry/conf/server.py index 841b87ba0c850..05f9b38ed8c73 100644 --- a/src/sentry/conf/server.py +++ b/src/sentry/conf/server.py @@ -401,6 +401,7 @@ def env( "sentry.users", "sentry.sentry_apps", "sentry.integrations", + "sentry.notifications", "sentry.flags", "sentry.monitors", "sentry.uptime", diff --git a/src/sentry/notifications/models/__init__.py b/src/sentry/notifications/models/__init__.py new file mode 100644 index 0000000000000..af3d50ab806ef --- /dev/null +++ b/src/sentry/notifications/models/__init__.py @@ -0,0 +1,3 @@ +from sentry.notifications.models.notificationsettingoption import NotificationSettingOption + +__all__ = ("NotificationSettingOption",)