Skip to content

Commit 0e4b091

Browse files
committed
New NotificationMessage model.
1 parent 1e8b295 commit 0e4b091

2 files changed

Lines changed: 127 additions & 0 deletions

File tree

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
# Generated by Django 4.2.20 on 2025-10-06 14:10
2+
3+
from django.conf import settings
4+
from django.db import migrations, models
5+
import django.db.models.deletion
6+
import uuid
7+
8+
9+
class Migration(migrations.Migration):
10+
11+
dependencies = [
12+
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
13+
("core", "0055_archiveexport"),
14+
]
15+
16+
operations = [
17+
migrations.CreateModel(
18+
name="NotificationMessage",
19+
fields=[
20+
(
21+
"id",
22+
models.UUIDField(
23+
default=uuid.uuid4,
24+
editable=False,
25+
help_text="Unique identifier.",
26+
primary_key=True,
27+
serialize=False,
28+
),
29+
),
30+
(
31+
"type",
32+
models.CharField(
33+
choices=[("INTERNAL", "INTERNAL"), ("MAIL", "MAIL")],
34+
default="INTERNAL",
35+
help_text="Notification type.",
36+
max_length=16,
37+
verbose_name="Notification type",
38+
),
39+
),
40+
("requested_at", models.DateTimeField(auto_now_add=True, help_text="Notification request date.")),
41+
("processed_at", models.DateTimeField(editable=False, help_text="Notification process date.")),
42+
("success", models.BooleanField(editable=False, help_text="Notification process result success.")),
43+
(
44+
"template_path",
45+
models.CharField(
46+
default="",
47+
help_text="Internal template path used to generate the notification content with the given context.",
48+
max_length=512,
49+
verbose_name="template_path",
50+
),
51+
),
52+
(
53+
"context",
54+
models.JSONField(
55+
default=dict, verbose_name="Template context used to generate the notification content."
56+
),
57+
),
58+
(
59+
"recipient",
60+
models.ForeignKey(
61+
on_delete=django.db.models.deletion.CASCADE,
62+
related_name="notifications",
63+
to=settings.AUTH_USER_MODEL,
64+
),
65+
),
66+
],
67+
),
68+
]

colander/core/models.py

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,14 @@ class ExportType:
9494
(CASE, 'CASE'),
9595
]
9696

97+
class NotificationType:
98+
INTERNAL = 'INTERNAL'
99+
MAIL = 'MAIL'
100+
NOTIFICATION_TYPE_CHOICES = [
101+
(INTERNAL, 'INTERNAL'),
102+
(MAIL, 'MAIL'),
103+
]
104+
97105
def list_accepted_levels(input_level: str):
98106
triggered = False
99107
levels = []
@@ -2647,6 +2655,57 @@ def delete_dropped_file_stored_file(sender, instance: ArchiveExport, using, **kw
26472655
instance.file.delete()
26482656

26492657

2658+
class NotificationMessage(models.Model):
2659+
id = models.UUIDField(
2660+
primary_key=True,
2661+
default=uuid.uuid4,
2662+
help_text=_('Unique identifier.'),
2663+
editable=False
2664+
)
2665+
2666+
recipient = models.ForeignKey(
2667+
settings.AUTH_USER_MODEL,
2668+
on_delete=models.CASCADE,
2669+
related_name='notifications',
2670+
)
2671+
2672+
type = models.CharField(
2673+
max_length=16,
2674+
choices=Appendix.NotificationType.NOTIFICATION_TYPE_CHOICES,
2675+
help_text=_('Notification type.'),
2676+
verbose_name='Notification type',
2677+
default=Appendix.NotificationType.INTERNAL,
2678+
)
2679+
2680+
requested_at = models.DateTimeField(
2681+
auto_now_add=True,
2682+
help_text=_('Notification request date.'),
2683+
editable=False
2684+
)
2685+
2686+
processed_at = models.DateTimeField(
2687+
help_text=_('Notification process date.'),
2688+
editable=False
2689+
)
2690+
2691+
success = models.BooleanField(
2692+
help_text=_('Notification process result success.'),
2693+
editable=False
2694+
)
2695+
2696+
template_path = models.CharField(
2697+
max_length=512,
2698+
verbose_name=_('template_path'),
2699+
help_text=_('Internal template path used to generate the notification content with the given context.'),
2700+
default='',
2701+
)
2702+
2703+
context = JSONField(
2704+
verbose_name='Template context used to generate the notification content.',
2705+
default=dict,
2706+
)
2707+
2708+
26502709
colander_models = CaseInsensitiveDict({
26512710
'Case': Case,
26522711
'Actor': Actor,

0 commit comments

Comments
 (0)