コード例 #1
0
ファイル: contact.py プロジェクト: chrisblythe812/gamemine
 def create_mailinglist(self, request, queryset):
     when = str(datetime.now()).split(".")[0]
     new_mailing = MailingList(
         name=u"%s %s" % (_(u"New List at"), when),
         description=u"",
         type=MailingList.PRIVATE,
         behavior=MailingList.STATIC,
     )
     new_mailing.save()
     new_mailing.subscribers = queryset
     self.message_user(request, u"%s %s" % (new_mailing, _(u"New list in")))
コード例 #2
0
    def merge_mailinglist(self, request, queryset):
        if queryset.filter(behavior=MailingList.DYNAMIC).count() > 0:
            messages.warning(request,_('you can not merge dynamic list.'))
            return None
                
        queryset = queryset.filter(type=MailingList.PRIVATE)
        if queryset.count() <= 1:
            messages.warning(request, _('Please choose at least two private lists.'))
            return None

        
        contacts = []
        for ml in queryset:
            for contact in ml.subscribers.all():
                contacts.append(contact)

        when = str(datetime.now()).split('.')[0]
        new_mailing = MailingList(name= u'%s %s' % (_(u'New list at'),when),
                                  description= u'%s %s' % (_(u'Created New list based on merging other at'),when),
                                  type=MailingList.PRIVATE,behavior=MailingList.STATIC)
        new_mailing.save()
        new_mailing.subscribers = set(contacts)

        self.message_user(request, u'%s %s'  % (new_mailing,_(u'Created successfully')) )