本文整理汇总了Python中emencia.django.newsletter.models.MailingList.unsubscribers方法的典型用法代码示例。如果您正苦于以下问题:Python MailingList.unsubscribers方法的具体用法?Python MailingList.unsubscribers怎么用?Python MailingList.unsubscribers使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类emencia.django.newsletter.models.MailingList
的用法示例。
在下文中一共展示了MailingList.unsubscribers方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: merge_mailinglist
# 需要导入模块: from emencia.django.newsletter.models import MailingList [as 别名]
# 或者: from emencia.django.newsletter.models.MailingList import unsubscribers [as 别名]
def merge_mailinglist(self, request, queryset):
"""Merge multiple mailing list"""
if queryset.count() == 1:
self.message_user(request, _('Please select a least 2 mailing list.'))
return None
subscribers = {}
unsubscribers = {}
for ml in queryset:
for contact in ml.subscribers.all():
subscribers[contact] = ''
for contact in ml.unsubscribers.all():
unsubscribers[contact] = ''
when = str(datetime.now()).split('.')[0]
new_mailing = MailingList(name=_('Merging list at %s') % when,
description=_('Mailing list created by merging at %s') % when)
new_mailing.save()
new_mailing.subscribers = subscribers.keys()
new_mailing.unsubscribers = unsubscribers.keys()
if not request.user.is_superuser and USE_WORKGROUPS:
for workgroup in request_workgroups(request):
workgroup.mailinglists.add(new_mailing)
self.message_user(request, _('%s succesfully created by merging.') % new_mailing)
return HttpResponseRedirect(reverse('admin:newsletter_mailinglist_change',
args=[new_mailing.pk]))