1
0
Fork 1
mirror of https://github.com/coddingtonbear/django-mailbox.git synced 2026-07-09 22:38:19 +02:00

Fix get_new_mail admin action.

Mailbox.get_new_mail returns a generator
which do not actually run if we do not iterate it.
This commit is contained in:
George Cheng 2020-07-26 04:55:46 +00:00
parent c8751f0c9a
commit 505bc8d1c9

View file

@ -20,9 +20,11 @@ logger = logging.getLogger(__name__)
def get_new_mail(mailbox_admin, request, queryset): def get_new_mail(mailbox_admin, request, queryset):
count = 0
for mailbox in queryset.all(): for mailbox in queryset.all():
logger.debug('Receiving mail for %s' % mailbox) logger.debug('Receiving mail for %s' % mailbox)
mailbox.get_new_mail() count += sum(1 for i in mailbox.get_new_mail())
logger.debug('Received %d %s.', count, 'mails' if count != 1 else 'mail')
get_new_mail.short_description = _('Get new mail') get_new_mail.short_description = _('Get new mail')