Skip to content

Commit

Permalink
DSRC-75: Add name to Alerts (#1690)
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesbiggs authored Jul 31, 2024
1 parent 1948195 commit 53ca0d8
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 2 deletions.
32 changes: 32 additions & 0 deletions etna/alerts/migrations/0003_alert_name_alter_alert_title.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Generated by Django 5.0.7 on 2024-07-30 14:28
# etna:allowAlterField

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
("alerts", "0002_alert_uid"),
]

operations = [
migrations.AddField(
model_name="alert",
name="name",
field=models.CharField(
default="replace",
help_text="The name of the alert to display in the CMS, for easier identification.",
max_length=100,
),
preserve_default=False,
),
migrations.AlterField(
model_name="alert",
name="title",
field=models.CharField(
help_text="The short title of your alert which will show in bold at the top of the notification banner. E.g. 'Please note' or 'Important information'",
max_length=50,
),
),
]
12 changes: 10 additions & 2 deletions etna/alerts/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,14 @@ class Alert(models.Model):
("high", "High"),
]

title = models.CharField(max_length=100)
name = models.CharField(
max_length=100,
help_text="The name of the alert to display in the CMS, for easier identification.",
)
title = models.CharField(
max_length=50,
help_text="The short title of your alert which will show in bold at the top of the notification banner. E.g. 'Please note' or 'Important information'",
)
message = RichTextField(features=settings.INLINE_RICH_TEXT_FEATURES)
active = models.BooleanField(default=False)
cascade = models.BooleanField(
Expand All @@ -52,6 +59,7 @@ class Alert(models.Model):
)

panels = [
FieldPanel("name"),
FieldPanel("title"),
FieldPanel("message"),
FieldPanel("active"),
Expand All @@ -62,7 +70,7 @@ class Alert(models.Model):
uid = models.BigIntegerField(null=False, blank=True, editable=False)

def __str__(self):
return self.title
return self.name

def save(self, *args, **kwargs):
self.uid = round(time.time() * 1000)
Expand Down

0 comments on commit 53ca0d8

Please sign in to comment.