remove all references to deprecated AlertGroup.is_restricted field (#3228)
# What this PR does remove all references to deprecated `AlertGroup.is_restricted` field + leave a note to remove the column in a future release
This commit is contained in:
parent
1b05b60738
commit
b8ad7bf99b
9 changed files with 13 additions and 24 deletions
|
|
@ -247,10 +247,9 @@ class EscalationSnapshotMixin:
|
|||
|
||||
is_on_maintenance_or_debug_mode = self.channel.maintenance_mode is not None
|
||||
|
||||
if self.is_restricted or is_on_maintenance_or_debug_mode or not self.escalation_chain_exists:
|
||||
if is_on_maintenance_or_debug_mode or not self.escalation_chain_exists:
|
||||
logger.debug(
|
||||
f"Not escalating alert group w/ pk: {self.pk}\n"
|
||||
f"is_restricted: {self.is_restricted}\n"
|
||||
f"is_on_maintenance_or_debug_mode: {is_on_maintenance_or_debug_mode}\n"
|
||||
f"escalation_chain_exists: {self.escalation_chain_exists}"
|
||||
)
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
from apps.alerts.incident_appearance.renderers.base_renderer import AlertBaseRenderer, AlertGroupBaseRenderer
|
||||
from apps.alerts.incident_appearance.templaters import AlertClassicMarkdownTemplater
|
||||
from common.constants.alert_group_restrictions import IS_RESTRICTED_MESSAGE, IS_RESTRICTED_TITLE
|
||||
from common.utils import str_or_backup
|
||||
|
||||
|
||||
|
|
@ -11,13 +10,11 @@ class AlertClassicMarkdownRenderer(AlertBaseRenderer):
|
|||
|
||||
def render(self):
|
||||
templated_alert = self.templated_alert
|
||||
is_restricted = self.alert.group.is_restricted
|
||||
|
||||
return {
|
||||
"title": IS_RESTRICTED_TITLE if is_restricted else str_or_backup(templated_alert.title, "Alert"),
|
||||
"message": IS_RESTRICTED_MESSAGE if is_restricted else str_or_backup(templated_alert.message, ""),
|
||||
"image_url": None if is_restricted else str_or_backup(templated_alert.image_url, None),
|
||||
"source_link": None if is_restricted else str_or_backup(templated_alert.source_link, None),
|
||||
"title": str_or_backup(templated_alert.title, "Alert"),
|
||||
"message": str_or_backup(templated_alert.message, ""),
|
||||
"image_url": str_or_backup(templated_alert.image_url, None),
|
||||
"source_link": str_or_backup(templated_alert.source_link, None),
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
from apps.alerts.incident_appearance.renderers.base_renderer import AlertBaseRenderer, AlertGroupBaseRenderer
|
||||
from apps.alerts.incident_appearance.templaters import AlertWebTemplater
|
||||
from common.constants.alert_group_restrictions import IS_RESTRICTED_MESSAGE, IS_RESTRICTED_TITLE
|
||||
from common.utils import str_or_backup
|
||||
|
||||
|
||||
|
|
@ -11,13 +10,11 @@ class AlertWebRenderer(AlertBaseRenderer):
|
|||
|
||||
def render(self):
|
||||
templated_alert = self.templated_alert
|
||||
is_restricted = self.alert.group.is_restricted
|
||||
|
||||
return {
|
||||
"title": IS_RESTRICTED_TITLE if is_restricted else str_or_backup(templated_alert.title, "Alert"),
|
||||
"message": IS_RESTRICTED_MESSAGE if is_restricted else str_or_backup(templated_alert.message, ""),
|
||||
"image_url": None if is_restricted else str_or_backup(templated_alert.image_url, None),
|
||||
"source_link": None if is_restricted else str_or_backup(templated_alert.source_link, None),
|
||||
"title": str_or_backup(templated_alert.title, "Alert"),
|
||||
"message": str_or_backup(templated_alert.message, ""),
|
||||
"image_url": str_or_backup(templated_alert.image_url, None),
|
||||
"source_link": str_or_backup(templated_alert.source_link, None),
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -389,6 +389,7 @@ class AlertGroup(AlertGroupSlackRenderingMixin, EscalationSnapshotMixin, models.
|
|||
# https://code.djangoproject.com/ticket/28545
|
||||
is_open_for_grouping = models.BooleanField(default=None, null=True, blank=True)
|
||||
|
||||
# TODO: drop this column in an upcoming release
|
||||
is_restricted = models.BooleanField(default=False, null=True)
|
||||
|
||||
@staticmethod
|
||||
|
|
|
|||
|
|
@ -71,5 +71,4 @@ class AlertRawSerializer(serializers.ModelSerializer):
|
|||
]
|
||||
|
||||
def get_raw_request_data(self, obj):
|
||||
# TODO:
|
||||
return {} if obj.group.is_restricted else obj.raw_request_data
|
||||
return obj.raw_request_data
|
||||
|
|
|
|||
|
|
@ -149,7 +149,6 @@ class AlertGroupListSerializer(EagerLoadingMixin, AlertGroupFieldsCacheSerialize
|
|||
"status",
|
||||
"declare_incident_link",
|
||||
"team",
|
||||
"is_restricted",
|
||||
]
|
||||
|
||||
@extend_schema_field(
|
||||
|
|
|
|||
|
|
@ -21,4 +21,4 @@ class AlertSerializer(EagerLoadingMixin, serializers.ModelSerializer):
|
|||
]
|
||||
|
||||
def get_payload(self, obj):
|
||||
return {} if obj.group.is_restricted else obj.raw_request_data
|
||||
return obj.raw_request_data
|
||||
|
|
|
|||
|
|
@ -4,7 +4,6 @@ from rest_framework import serializers
|
|||
from apps.alerts.models import AlertGroup
|
||||
from apps.telegram.models.message import TelegramMessage
|
||||
from common.api_helpers.mixins import EagerLoadingMixin
|
||||
from common.constants.alert_group_restrictions import IS_RESTRICTED_TITLE
|
||||
|
||||
|
||||
class IncidentSerializer(EagerLoadingMixin, serializers.ModelSerializer):
|
||||
|
|
@ -42,7 +41,7 @@ class IncidentSerializer(EagerLoadingMixin, serializers.ModelSerializer):
|
|||
]
|
||||
|
||||
def get_title(self, obj):
|
||||
return IS_RESTRICTED_TITLE if obj.is_restricted else obj.web_title_cache
|
||||
return obj.web_title_cache
|
||||
|
||||
def get_alerts_count(self, obj):
|
||||
return len(obj.alerts.all())
|
||||
|
|
|
|||
|
|
@ -1,2 +0,0 @@
|
|||
IS_RESTRICTED_TITLE = "UPGRADE TO SEE MORE"
|
||||
IS_RESTRICTED_MESSAGE = "UPGRADE TO SEE MORE"
|
||||
Loading…
Add table
Reference in a new issue