From d859a5d14a13d4e1340cb443b393e7950476d86e Mon Sep 17 00:00:00 2001 From: djperrefort Date: Wed, 7 Aug 2024 13:48:19 -0400 Subject: [PATCH] Adds subject field to notificcation model --- .../migrations/0003_notification_subject.py | 19 +++++++++++++++++++ keystone_api/apps/notifications/models.py | 1 + keystone_api/apps/notifications/shortcuts.py | 1 + 3 files changed, 21 insertions(+) create mode 100644 keystone_api/apps/notifications/migrations/0003_notification_subject.py diff --git a/keystone_api/apps/notifications/migrations/0003_notification_subject.py b/keystone_api/apps/notifications/migrations/0003_notification_subject.py new file mode 100644 index 00000000..98a83995 --- /dev/null +++ b/keystone_api/apps/notifications/migrations/0003_notification_subject.py @@ -0,0 +1,19 @@ +# Generated by Django 5.0.7 on 2024-08-07 17:47 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('notifications', '0002_alter_notification_notification_type'), + ] + + operations = [ + migrations.AddField( + model_name='notification', + name='subject', + field=models.TextField(default=''), + preserve_default=False, + ), + ] diff --git a/keystone_api/apps/notifications/models.py b/keystone_api/apps/notifications/models.py index dfff212c..cf296142 100644 --- a/keystone_api/apps/notifications/models.py +++ b/keystone_api/apps/notifications/models.py @@ -33,6 +33,7 @@ class NotificationType(models.TextChoices): time = models.DateTimeField(auto_now_add=True) read = models.BooleanField(default=False) + subject = models.TextField() message = models.TextField() metadata = models.JSONField(null=True) notification_type = models.CharField( diff --git a/keystone_api/apps/notifications/shortcuts.py b/keystone_api/apps/notifications/shortcuts.py index 5967266d..69db09d0 100644 --- a/keystone_api/apps/notifications/shortcuts.py +++ b/keystone_api/apps/notifications/shortcuts.py @@ -41,6 +41,7 @@ def send_notification( Notification.objects.create( user=user, + subject=subject, message=plain_text, notification_type=notification_type, metadata=notification_metadata