1
0
Fork 0

Add Mailbox.last_polling model field

This commit is contained in:
Adam Dobrawy 2016-08-16 01:00:26 +02:00
parent 8ce9a530f0
commit 086bcd3acd
2 changed files with 31 additions and 0 deletions

View file

@ -25,6 +25,7 @@ from django.core.files.base import ContentFile
from django.core.mail.message import make_msgid
from django.db import models
from django.utils.translation import ugettext_lazy as _
from django.utils.timezone import now
from django_mailbox import utils
from django_mailbox.signals import message_received
@ -96,6 +97,14 @@ class Mailbox(models.Model):
default=True,
)
last_polling = models.DateTimeField(
_(u"Last polling"),
help_text=(_("The time of last successfull polling of message. "
"It is blank for new mailbox or processing email via pipe only.")),
blank=True,
null=True
)
objects = models.Manager()
active_mailboxes = ActiveMailboxManager()
@ -372,6 +381,8 @@ class Mailbox(models.Model):
for message in connection.get_message(condition):
msg = self.process_incoming_message(message)
new_mail.append(msg)
self.last_polling = now()
self.save(update_fields=['last_polling'])
return new_mail
def __unicode__(self):