2012-06-27 20:45:01 -07:00
|
|
|
from django.conf import settings
|
|
|
|
|
from django.contrib import admin
|
|
|
|
|
|
2013-01-15 12:21:49 +00:00
|
|
|
from django_mailbox.models import MessageAttachment, Message, Mailbox
|
2012-06-27 20:45:01 -07:00
|
|
|
|
|
|
|
|
def get_new_mail(mailbox_admin, request, queryset):
|
|
|
|
|
for mailbox in queryset.all():
|
|
|
|
|
mailbox.get_new_mail()
|
|
|
|
|
get_new_mail.short_description = 'Get new mail'
|
|
|
|
|
|
|
|
|
|
class MailboxAdmin(admin.ModelAdmin):
|
|
|
|
|
list_display = (
|
|
|
|
|
'name',
|
|
|
|
|
'uri',
|
2012-10-28 12:41:36 -07:00
|
|
|
'from_email',
|
2012-10-09 05:52:04 +00:00
|
|
|
'active',
|
2012-06-27 20:45:01 -07:00
|
|
|
)
|
|
|
|
|
actions = [get_new_mail]
|
|
|
|
|
|
2013-01-15 12:21:49 +00:00
|
|
|
class MessageAttachmentAdmin(admin.ModelAdmin):
|
2013-01-15 12:27:32 +00:00
|
|
|
list_display = ('document',)
|
2013-01-15 12:21:49 +00:00
|
|
|
|
2012-06-27 20:45:01 -07:00
|
|
|
class MessageAdmin(admin.ModelAdmin):
|
|
|
|
|
list_display = (
|
|
|
|
|
'subject',
|
2012-10-09 05:52:04 +00:00
|
|
|
'processed',
|
2012-12-07 11:08:17 -08:00
|
|
|
'read',
|
2012-06-27 20:45:01 -07:00
|
|
|
'mailbox',
|
2012-10-09 05:52:04 +00:00
|
|
|
'outgoing',
|
|
|
|
|
)
|
|
|
|
|
ordering = ['-processed']
|
|
|
|
|
list_filter = (
|
|
|
|
|
'mailbox',
|
|
|
|
|
'outgoing',
|
2012-12-07 11:08:17 -08:00
|
|
|
'processed',
|
|
|
|
|
'read',
|
2012-10-09 05:52:04 +00:00
|
|
|
)
|
|
|
|
|
raw_id_fields = (
|
|
|
|
|
'in_reply_to',
|
2013-01-20 16:51:10 -08:00
|
|
|
'attachments',
|
2012-06-27 20:45:01 -07:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
if getattr(settings, 'DJANGO_MAILBOX_ADMIN_ENABLED', True):
|
|
|
|
|
admin.site.register(Message, MessageAdmin)
|
2013-01-15 12:23:16 +00:00
|
|
|
admin.site.register(MessageAttachment, MessageAttachmentAdmin)
|
2012-06-27 20:45:01 -07:00
|
|
|
admin.site.register(Mailbox, MailboxAdmin)
|