Skip to content

Commit

Permalink
remove all references to deprecated AlertGroup.is_restricted field (#…
Browse files Browse the repository at this point in the history
…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
  • Loading branch information
joeyorlando authored Oct 31, 2023
1 parent 1b05b60 commit b8ad7bf
Show file tree
Hide file tree
Showing 9 changed files with 13 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -247,10 +247,9 @@ def start_escalation_if_needed(self, countdown=START_ESCALATION_DELAY, eta=None)

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}"
)
Expand Down
Original file line number Diff line number Diff line change
@@ -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


Expand All @@ -11,13 +10,11 @@ def templater_class(self):

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),
}


Expand Down
11 changes: 4 additions & 7 deletions engine/apps/alerts/incident_appearance/renderers/web_renderer.py
Original file line number Diff line number Diff line change
@@ -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


Expand All @@ -11,13 +10,11 @@ def templater_class(self):

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),
}


Expand Down
1 change: 1 addition & 0 deletions engine/apps/alerts/models/alert_group.py
Original file line number Diff line number Diff line change
Expand Up @@ -389,6 +389,7 @@ def status(self):
# 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
Expand Down
3 changes: 1 addition & 2 deletions engine/apps/api/serializers/alert.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,5 +71,4 @@ class Meta:
]

def get_raw_request_data(self, obj):
# TODO:
return {} if obj.group.is_restricted else obj.raw_request_data
return obj.raw_request_data
1 change: 0 additions & 1 deletion engine/apps/api/serializers/alert_group.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,6 @@ class Meta:
"status",
"declare_incident_link",
"team",
"is_restricted",
]

@extend_schema_field(
Expand Down
2 changes: 1 addition & 1 deletion engine/apps/public_api/serializers/alerts.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ class Meta:
]

def get_payload(self, obj):
return {} if obj.group.is_restricted else obj.raw_request_data
return obj.raw_request_data
3 changes: 1 addition & 2 deletions engine/apps/public_api/serializers/incidents.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
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):
Expand Down Expand Up @@ -42,7 +41,7 @@ class Meta:
]

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())
Expand Down
2 changes: 0 additions & 2 deletions engine/common/constants/alert_group_restrictions.py

This file was deleted.

0 comments on commit b8ad7bf

Please sign in to comment.