当前位置: 首页>>代码示例>>Python>>正文


Python MailingList.subscribers方法代码示例

本文整理汇总了Python中emencia.django.newsletter.models.MailingList.subscribers方法的典型用法代码示例。如果您正苦于以下问题:Python MailingList.subscribers方法的具体用法?Python MailingList.subscribers怎么用?Python MailingList.subscribers使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在emencia.django.newsletter.models.MailingList的用法示例。


在下文中一共展示了MailingList.subscribers方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: create_mailinglist

# 需要导入模块: from emencia.django.newsletter.models import MailingList [as 别名]
# 或者: from emencia.django.newsletter.models.MailingList import subscribers [as 别名]
    def create_mailinglist(self, request, queryset):
        """Create a mailing list from selected contact"""
        when = str(datetime.now()).split('.')[0]
        new_mailing = MailingList(
            name=_('New mailinglist at %s') % when,
            description=_('New mailing list created in admin at %s') % when)
        new_mailing.save()

        if 'lite' in settings.DATABASES['default']['ENGINE']:
            self.message_user(
                request,
                _('SQLite3 or a SpatialLite database type detected, ' \
                  'please note you will be limited to 999 contacts ' \
                  'per mailing list.')
            )
        try:
            new_mailing.subscribers = queryset.all()
        except DatabaseError:
            new_mailing.subscribers = queryset.none()

        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.') % new_mailing)
        return HttpResponseRedirect(reverse(
            'admin:newsletter_mailinglist_change',
            args=[new_mailing.pk]
        ))
开发者ID:strycore,项目名称:emencia-django-newsletter,代码行数:31,代码来源:contact.py

示例2: merge_mailinglist

# 需要导入模块: from emencia.django.newsletter.models import MailingList [as 别名]
# 或者: from emencia.django.newsletter.models.MailingList import subscribers [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]))
开发者ID:calendar42,项目名称:emencia-django-newsletter,代码行数:30,代码来源:mailinglist.py

示例3: create_mailinglist

# 需要导入模块: from emencia.django.newsletter.models import MailingList [as 别名]
# 或者: from emencia.django.newsletter.models.MailingList import subscribers [as 别名]
    def create_mailinglist(self, request, queryset):
        """Create a mailing list from selected contact"""
        when = str(datetime.now()).split('.')[0]
        new_mailing = MailingList(name=_('New mailinglist at %s') % when,
                                  description=_('New mailing list created in admin at %s') % when)
        new_mailing.save()
        new_mailing.subscribers = queryset.all()

        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.') % new_mailing)
        return HttpResponseRedirect(reverse('admin:newsletter_mailinglist_change',
                                            args=[new_mailing.pk]))
开发者ID:drye,项目名称:emencia-django-newsletter,代码行数:17,代码来源:contact.py

示例4: merge_mailinglist

# 需要导入模块: from emencia.django.newsletter.models import MailingList [as 别名]
# 或者: from emencia.django.newsletter.models.MailingList import subscribers [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

        contacts = {}
        for ml in queryset:
            for contact in ml.subscribers.all():
                contacts[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 = contacts.keys()

        self.message_user(request, _('%s succesfully created by merging.') % new_mailing)
        return HttpResponseRedirect(reverse('admin:newsletter_mailinglist_change',
                                            args=[new_mailing.pk,]))
开发者ID:korkakak,项目名称:emencia-django-newsletter,代码行数:22,代码来源:mailinglist.py


注:本文中的emencia.django.newsletter.models.MailingList.subscribers方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。