Skip to content

Commit ebbec27

Browse files
committed
Add a "date_sent" field to detect when the mail was sent
Closes #43
1 parent 77ba640 commit ebbec27

File tree

5 files changed

+24
-2
lines changed

5 files changed

+24
-2
lines changed

demo/demo.sqlite

28 KB
Binary file not shown.

django_yubin/admin.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ def message_link(self, obj):
2929
message_link.allow_tags = True
3030
message_link.short_description = u'Show'
3131

32-
list_display = ('from_address', 'to_address', 'subject', 'date_created', 'message_link')
33-
list_filter = ('date_created',)
32+
list_display = ('from_address', 'to_address', 'subject', 'date_created', 'date_sent', 'message_link')
33+
list_filter = ('date_created', 'date_sent')
3434
search_fields = ('to_address', 'subject', 'from_address',
3535
'encoded_message',)
3636
date_hierarchy = 'date_created'

django_yubin/engine.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
1010
"""
1111
from django.utils.encoding import smart_str
12+
from django.utils.timezone import now
1213
from django_yubin import constants, models, settings
1314
from lockfile import FileLock, AlreadyLocked, LockTimeout
1415
from socket import error as SocketError
@@ -211,6 +212,8 @@ def send_queued_message(queued_message, smtp_connection=None, blacklist=None,
211212
message.from_address,
212213
[message.to_address],
213214
smart_str(message.encoded_message).encode('utf-8'))
215+
queued_message.message.date_sent = now()
216+
queued_message.message.save()
214217
queued_message.delete()
215218
result = constants.RESULT_SENT
216219
except (SocketError, smtplib.SMTPSenderRefused,
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Generated by Django 2.0.6 on 2018-06-27 14:12
2+
3+
from django.db import migrations, models
4+
5+
6+
class Migration(migrations.Migration):
7+
8+
dependencies = [
9+
('django_yubin', '0003_auto_20171201_1506'),
10+
]
11+
12+
operations = [
13+
migrations.AddField(
14+
model_name='message',
15+
name='date_sent',
16+
field=models.DateTimeField(blank=True, null=True),
17+
),
18+
]

django_yubin/models.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ class Message(models.Model):
4141

4242
encoded_message = models.TextField()
4343
date_created = models.DateTimeField(default=now)
44+
date_sent = models.DateTimeField(null=True, blank=True)
4445

4546
class Meta:
4647
ordering = ('date_created',)

0 commit comments

Comments
 (0)