forked from mirror/django-mailbox
Adding unread/read flagging for individual messages.
This commit is contained in:
parent
5c285017ca
commit
af58c324f5
4 changed files with 61 additions and 1 deletions
1
MANIFEST
1
MANIFEST
|
|
@ -18,6 +18,7 @@ django_mailbox/migrations/0007_auto__del_field_message_address__add_field_messag
|
|||
django_mailbox/migrations/0008_populate_from_to_fields.py
|
||||
django_mailbox/migrations/0009_remove_references_table.py
|
||||
django_mailbox/migrations/0010_auto__add_field_mailbox_from_email.py
|
||||
django_mailbox/migrations/0011_auto__add_field_message_read.py
|
||||
django_mailbox/migrations/__init__.py
|
||||
django_mailbox/transports/__init__.py
|
||||
django_mailbox/transports/babyl.py
|
||||
|
|
|
|||
|
|
@ -0,0 +1,47 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
import datetime
|
||||
from south.db import db
|
||||
from south.v2 import SchemaMigration
|
||||
from django.db import models
|
||||
|
||||
|
||||
class Migration(SchemaMigration):
|
||||
|
||||
def forwards(self, orm):
|
||||
# Adding field 'Message.read'
|
||||
db.add_column('django_mailbox_message', 'read',
|
||||
self.gf('django.db.models.fields.DateTimeField')(default=None, null=True, blank=True),
|
||||
keep_default=False)
|
||||
|
||||
|
||||
def backwards(self, orm):
|
||||
# Deleting field 'Message.read'
|
||||
db.delete_column('django_mailbox_message', 'read')
|
||||
|
||||
|
||||
models = {
|
||||
'django_mailbox.mailbox': {
|
||||
'Meta': {'object_name': 'Mailbox'},
|
||||
'active': ('django.db.models.fields.BooleanField', [], {'default': 'True'}),
|
||||
'from_email': ('django.db.models.fields.CharField', [], {'default': 'None', 'max_length': '255', 'null': 'True', 'blank': 'True'}),
|
||||
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
|
||||
'name': ('django.db.models.fields.CharField', [], {'max_length': '255'}),
|
||||
'uri': ('django.db.models.fields.CharField', [], {'default': 'None', 'max_length': '255', 'null': 'True', 'blank': 'True'})
|
||||
},
|
||||
'django_mailbox.message': {
|
||||
'Meta': {'object_name': 'Message'},
|
||||
'body': ('django.db.models.fields.TextField', [], {}),
|
||||
'from_header': ('django.db.models.fields.CharField', [], {'max_length': '255'}),
|
||||
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
|
||||
'in_reply_to': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'replies'", 'null': 'True', 'to': "orm['django_mailbox.Message']"}),
|
||||
'mailbox': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'messages'", 'to': "orm['django_mailbox.Mailbox']"}),
|
||||
'message_id': ('django.db.models.fields.CharField', [], {'max_length': '255'}),
|
||||
'outgoing': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
|
||||
'processed': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}),
|
||||
'read': ('django.db.models.fields.DateTimeField', [], {'default': 'None', 'null': 'True', 'blank': 'True'}),
|
||||
'subject': ('django.db.models.fields.CharField', [], {'max_length': '255'}),
|
||||
'to_header': ('django.db.models.fields.TextField', [], {})
|
||||
}
|
||||
}
|
||||
|
||||
complete_apps = ['django_mailbox']
|
||||
|
|
@ -190,6 +190,12 @@ class OutgoingMessageManager(models.Manager):
|
|||
outgoing=True,
|
||||
)
|
||||
|
||||
class UnreadMessageManager(models.Manager):
|
||||
def get_query_set(self):
|
||||
return super(UnreadMessageManager, self).get_query_set().filter(
|
||||
read=None
|
||||
)
|
||||
|
||||
class Message(models.Model):
|
||||
mailbox = models.ForeignKey(Mailbox, related_name='messages')
|
||||
subject = models.CharField(max_length=255)
|
||||
|
|
@ -214,8 +220,14 @@ class Message(models.Model):
|
|||
processed = models.DateTimeField(
|
||||
auto_now_add=True
|
||||
)
|
||||
read = models.DateTimeField(
|
||||
default=None,
|
||||
blank=True,
|
||||
null=True,
|
||||
)
|
||||
|
||||
objects = models.Manager()
|
||||
unread_messages = UnreadMessageManager()
|
||||
incoming_messages = IncomingMessageManager()
|
||||
outgoing_messages = OutgoingMessageManager()
|
||||
|
||||
|
|
|
|||
2
setup.py
2
setup.py
|
|
@ -2,7 +2,7 @@ from distutils.core import setup
|
|||
|
||||
setup(
|
||||
name='django-mailbox',
|
||||
version='1.3',
|
||||
version='1.4',
|
||||
url='http://bitbucket.org/latestrevision/django-mailbox/',
|
||||
description='Import mail from POP3, IMAP, local mailboxes or directly from Postfix or Exim4 into your Django application automatically.',
|
||||
author='Adam Coddington',
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue