mirror of
https://github.com/coddingtonbear/django-mailbox.git
synced 2026-07-09 22:38:19 +02:00
Add Mailbox.last_polling model field
This commit is contained in:
parent
8ce9a530f0
commit
086bcd3acd
2 changed files with 31 additions and 0 deletions
20
django_mailbox/migrations/0006_mailbox_last_polling.py
Normal file
20
django_mailbox/migrations/0006_mailbox_last_polling.py
Normal file
|
|
@ -0,0 +1,20 @@
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
# Generated by Django 1.9.8 on 2016-08-15 22:39
|
||||||
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('django_mailbox', '0005_auto_20160523_2240'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='mailbox',
|
||||||
|
name='last_polling',
|
||||||
|
field=models.DateTimeField(blank=True, null=True, help_text='The time of last successfull polling of message. It is blank for new mailbox or processing email via pipe only.', verbose_name='Last polling'),
|
||||||
|
),
|
||||||
|
]
|
||||||
|
|
@ -25,6 +25,7 @@ from django.core.files.base import ContentFile
|
||||||
from django.core.mail.message import make_msgid
|
from django.core.mail.message import make_msgid
|
||||||
from django.db import models
|
from django.db import models
|
||||||
from django.utils.translation import ugettext_lazy as _
|
from django.utils.translation import ugettext_lazy as _
|
||||||
|
from django.utils.timezone import now
|
||||||
|
|
||||||
from django_mailbox import utils
|
from django_mailbox import utils
|
||||||
from django_mailbox.signals import message_received
|
from django_mailbox.signals import message_received
|
||||||
|
|
@ -96,6 +97,14 @@ class Mailbox(models.Model):
|
||||||
default=True,
|
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()
|
objects = models.Manager()
|
||||||
active_mailboxes = ActiveMailboxManager()
|
active_mailboxes = ActiveMailboxManager()
|
||||||
|
|
||||||
|
|
@ -372,6 +381,8 @@ class Mailbox(models.Model):
|
||||||
for message in connection.get_message(condition):
|
for message in connection.get_message(condition):
|
||||||
msg = self.process_incoming_message(message)
|
msg = self.process_incoming_message(message)
|
||||||
new_mail.append(msg)
|
new_mail.append(msg)
|
||||||
|
self.last_polling = now()
|
||||||
|
self.save(update_fields=['last_polling'])
|
||||||
return new_mail
|
return new_mail
|
||||||
|
|
||||||
def __unicode__(self):
|
def __unicode__(self):
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue