Make notification rule ID field UUID and fix default sources

This commit is contained in:
Mark Veidemanis 2023-02-02 19:35:27 +00:00
parent 97e932cbae
commit 79b4512546
Signed by: m
GPG Key ID: 5ACFCEED46C0904F
5 changed files with 44 additions and 2 deletions

View File

@ -300,7 +300,7 @@ class ElasticsearchBackend(StorageBackend):
search_query, search_query,
index=index, index=index,
) )
# self.log.debug(f"Running scheduled query on {index}: {search_query}") self.log.debug(f"Running scheduled query on {index}: {search_query}")
# self.log.debug(f"Response from scheduled query: {response}") # self.log.debug(f"Response from scheduled query: {response}")
if isinstance(response, Exception): if isinstance(response, Exception):
error = response.info["error"]["root_cause"][0]["reason"] error = response.info["error"]["root_cause"][0]["reason"]

View File

@ -564,7 +564,7 @@ class NotificationRuleData(object):
else: else:
# Get the default value for the user if not present # Get the default value for the user if not present
source = parse_source(self.user, {}, raise_error=True) source = parse_source(self.user, {}, raise_error=True)
self.parsed["source"] = [source] self.parsed["source"] = source
def parse_data(self): def parse_data(self):
""" """

View File

@ -0,0 +1,19 @@
# Generated by Django 4.1.5 on 2023-02-02 19:08
from django.db import migrations, models
import uuid
class Migration(migrations.Migration):
dependencies = [
('core', '0023_alter_perms_options'),
]
operations = [
migrations.AlterField(
model_name='notificationrule',
name='id',
field=models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False),
),
]

View File

@ -0,0 +1,19 @@
# Generated by Django 4.1.5 on 2023-02-02 19:35
from django.db import migrations, models
import uuid
class Migration(migrations.Migration):
dependencies = [
('core', '0024_alter_notificationrule_id'),
]
operations = [
migrations.AlterField(
model_name='notificationrule',
name='id',
field=models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False, unique=True),
),
]

View File

@ -1,4 +1,5 @@
import logging import logging
import uuid
import stripe import stripe
from django.conf import settings from django.conf import settings
@ -175,6 +176,9 @@ class Perms(models.Model):
class NotificationRule(models.Model): class NotificationRule(models.Model):
id = models.UUIDField(
default=uuid.uuid4, primary_key=True, editable=False, unique=True
)
user = models.ForeignKey(User, on_delete=models.CASCADE) user = models.ForeignKey(User, on_delete=models.CASCADE)
name = models.CharField(max_length=255) name = models.CharField(max_length=255)
priority = models.IntegerField(choices=PRIORITY_CHOICES, default=1) priority = models.IntegerField(choices=PRIORITY_CHOICES, default=1)