Skip to content

Commit 2b1014d

Browse files
committed
Added a 'sent' field to Message, to be able to track sent status for captured outgoing messages (which don't have a SendQueue instance).
- Legacy-Id: 17340
1 parent fa4adeb commit 2b1014d

3 files changed

Lines changed: 60 additions & 1 deletion

File tree

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Copyright The IETF Trust 2020, All Rights Reserved
2+
# -*- coding: utf-8 -*-
3+
# Generated by Django 1.11.27 on 2020-02-22 09:29
4+
from __future__ import unicode_literals
5+
6+
from django.db import migrations, models
7+
8+
9+
class Migration(migrations.Migration):
10+
11+
dependencies = [
12+
('message', '0006_remove_docs2_m2m'),
13+
]
14+
15+
operations = [
16+
migrations.AddField(
17+
model_name='message',
18+
name='sent',
19+
field=models.DateTimeField(blank=True, null=True),
20+
),
21+
]
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# Copyright The IETF Trust 2020, All Rights Reserved
2+
# -*- coding: utf-8 -*-
3+
# Generated by Django 1.11.20 on 2019-05-21 14:27
4+
5+
6+
from __future__ import absolute_import, print_function, unicode_literals
7+
8+
from tqdm import tqdm
9+
10+
from django.db import migrations
11+
12+
13+
def forward(apps, schema_editor):
14+
15+
Message = apps.get_model('message', 'Message')
16+
17+
for m in tqdm(Message.objects.filter(sent=None)):
18+
if m.sendqueue_set.exists():
19+
q = m.sendqueue_set.last()
20+
m.sent = q.sent_at
21+
else:
22+
m.sent = m.time
23+
m.save()
24+
25+
def reverse(apps, schema_editor):
26+
pass
27+
28+
class Migration(migrations.Migration):
29+
30+
dependencies = [
31+
('message', '0007_message_sent'),
32+
]
33+
34+
operations = [
35+
migrations.RunPython(forward, reverse),
36+
]

ietf/message/models.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright The IETF Trust 2012-2019, All Rights Reserved
1+
# Copyright The IETF Trust 2012-2020, All Rights Reserved
22
# -*- coding: utf-8 -*-
33

44

@@ -37,6 +37,8 @@ class Message(models.Model):
3737
related_groups = models.ManyToManyField(Group, blank=True)
3838
related_docs = models.ManyToManyField(Document, blank=True)
3939

40+
sent = models.DateTimeField(blank=True, null=True)
41+
4042
class Meta:
4143
ordering = ['time']
4244

0 commit comments

Comments
 (0)