mirror of
https://github.com/coddingtonbear/django-mailbox.git
synced 2026-07-09 22:38:19 +02:00
Adding 'resend message received' admin action.
This commit is contained in:
parent
a44d6d87d9
commit
11eb186978
2 changed files with 14 additions and 1 deletions
|
|
@ -1,13 +1,25 @@
|
||||||
|
import logging
|
||||||
|
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from django.contrib import admin
|
from django.contrib import admin
|
||||||
|
|
||||||
from django_mailbox.models import MessageAttachment, Message, Mailbox
|
from django_mailbox.models import MessageAttachment, Message, Mailbox
|
||||||
|
from django_mailbox.signals import message_received
|
||||||
|
|
||||||
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
def get_new_mail(mailbox_admin, request, queryset):
|
def get_new_mail(mailbox_admin, request, queryset):
|
||||||
for mailbox in queryset.all():
|
for mailbox in queryset.all():
|
||||||
|
logger.debug('Receiving mail for %s' % mailbox)
|
||||||
mailbox.get_new_mail()
|
mailbox.get_new_mail()
|
||||||
get_new_mail.short_description = 'Get new mail'
|
get_new_mail.short_description = 'Get new mail'
|
||||||
|
|
||||||
|
def resend_message_received_signal(message_admin, request, queryset):
|
||||||
|
for message in queryset.all():
|
||||||
|
logger.debug('Resending \'message_received\' signal for %s' % message)
|
||||||
|
message_received.send(sender=message_admin, message=message)
|
||||||
|
resend_message_received_signal.short_description = 'Re-send message received signal'
|
||||||
|
|
||||||
class MailboxAdmin(admin.ModelAdmin):
|
class MailboxAdmin(admin.ModelAdmin):
|
||||||
list_display = (
|
list_display = (
|
||||||
'name',
|
'name',
|
||||||
|
|
@ -39,6 +51,7 @@ class MessageAdmin(admin.ModelAdmin):
|
||||||
'in_reply_to',
|
'in_reply_to',
|
||||||
'attachments',
|
'attachments',
|
||||||
)
|
)
|
||||||
|
actions = [resend_message_received_signal]
|
||||||
|
|
||||||
if getattr(settings, 'DJANGO_MAILBOX_ADMIN_ENABLED', True):
|
if getattr(settings, 'DJANGO_MAILBOX_ADMIN_ENABLED', True):
|
||||||
admin.site.register(Message, MessageAdmin)
|
admin.site.register(Message, MessageAdmin)
|
||||||
|
|
|
||||||
2
setup.py
2
setup.py
|
|
@ -4,7 +4,7 @@ tests_require=['django']
|
||||||
|
|
||||||
setup(
|
setup(
|
||||||
name='django-mailbox',
|
name='django-mailbox',
|
||||||
version='1.8.1',
|
version='1.8.2',
|
||||||
url='http://bitbucket.org/latestrevision/django-mailbox/',
|
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.',
|
description='Import mail from POP3, IMAP, local mailboxes or directly from Postfix or Exim4 into your Django application automatically.',
|
||||||
author='Adam Coddington',
|
author='Adam Coddington',
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue