Browse Source

chore(notifications): move over notificationsettingoption (#80836)

Christinarlong 3 months ago
parent
commit
cde9809b30

+ 1 - 1
src/sentry/api/endpoints/user_notification_settings_options.py

@@ -8,7 +8,7 @@ from sentry.api.base import control_silo_endpoint
 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

+ 1 - 1
src/sentry/api/endpoints/user_notification_settings_options_detail.py

@@ -6,7 +6,7 @@ from rest_framework.response import Response
 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
 

+ 1 - 0
src/sentry/conf/server.py

@@ -401,6 +401,7 @@ INSTALLED_APPS: tuple[str, ...] = (
     "sentry.users",
     "sentry.sentry_apps",
     "sentry.integrations",
+    "sentry.notifications",
     "sentry.flags",
     "sentry.monitors",
     "sentry.uptime",

+ 0 - 1
src/sentry/models/__init__.py

@@ -61,7 +61,6 @@ from .grouptombstone import *  # NOQA
 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

+ 2 - 39
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",)

+ 3 - 0
src/sentry/notifications/models/__init__.py

@@ -0,0 +1,3 @@
+from sentry.notifications.models.notificationsettingoption import NotificationSettingOption
+
+__all__ = ("NotificationSettingOption",)

+ 39 - 0
src/sentry/notifications/models/notificationsettingoption.py

@@ -0,0 +1,39 @@
+from django.db import models
+
+from sentry.backup.scopes import RelocationScope
+from sentry.db.models import control_silo_model, sane_repr
+from sentry.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",
+    )

+ 1 - 1
src/sentry/notifications/notificationcontroller.py

@@ -14,7 +14,6 @@ from sentry.integrations.types import (
     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 @@ from sentry.notifications.helpers import (
     recipient_is_user,
     team_is_valid_recipient,
 )
+from sentry.notifications.models.notificationsettingoption import NotificationSettingOption
 from sentry.notifications.types import (
     GroupSubscriptionStatus,
     NotificationScopeEnum,

+ 1 - 1
src/sentry/notifications/serializers.py

@@ -4,8 +4,8 @@ from collections.abc import Mapping
 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):

+ 1 - 1
src/sentry/notifications/services/impl.py

@@ -5,8 +5,8 @@ from collections.abc import Mapping, MutableMapping
 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

Some files were not shown because too many files changed in this diff