Beispiel #1
0
 def save_model(self, request, contact, form, change):
     workgroups = []
     if not contact.pk and not request.user.is_superuser:
         workgroups = request_workgroups(request)
     contact.save()
     for workgroup in workgroups:
         workgroup.contacts.add(contact)
 def save_model(self, request, mailinglist, form, change):
     workgroups = []
     if not mailinglist.pk and not request.user.is_superuser:
         workgroups = request_workgroups(request)
     mailinglist.save()
     for workgroup in workgroups:
         workgroup.mailinglists.add(mailinglist)
Beispiel #3
0
    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:
            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,]))
Beispiel #4
0
    def importation(self, request):
        """Import contacts from a VCard"""
        opts = self.model._meta

        if request.FILES:
            source = request.FILES.get('source')
            inserted = vcard_contacts_import(source, request_workgroups(request))
            self.message_user(request, _('%s contacts succesfully imported.') % inserted)

        context = {'title': _('VCard import'),
                   'opts': opts,
                   'root_path': self.admin_site.root_path,
                   'app_label': opts.app_label}

        return render_to_response('newsletter/contact_import.html',
                                  context, RequestContext(request))
    def save_model(self, request, newsletter, form, change):
        workgroups = []
        if not newsletter.pk and not request.user.is_superuser:
            workgroups = request_workgroups(request)

        if newsletter.content.startswith('http://'):
            try:
                newsletter.content = get_webpage_content(newsletter.content)
            except HTMLParseError:
                self.message_user(request, _('Unable to download HTML, due to errors within.'))

        if not request.user.has_perm('newsletter.can_change_status'):
            newsletter.status = form.initial.get('status', Newsletter.DRAFT)

        newsletter.save()

        for workgroup in workgroups:
            workgroup.newsletters.add(newsletter)