Esempio n. 1
0
    def importation(self, request):
        """Import contacts from a VCard"""
        opts = self.model._meta

        if request.POST:
            source = request.FILES.get('source') or \
                     StringIO.StringIO(request.POST.get('source', ''))
            if not request.user.is_superuser and USE_WORKGROUPS:
                workgroups = request_workgroups(request)
            else:
                workgroups = []
            inserted = import_dispatcher(source, request.POST['type'],
                                         workgroups)
            if inserted:
                contacts_imported.send(sender=self, source=source,
                                       type=request.POST['type'])

            self.message_user(request, _('%s contacts succesfully imported.') % inserted)

        context = {'title': _('Contact importation'),
                   '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 importation(self, request):
        """Import contacts from a VCard"""
        opts = self.model._meta

        if request.FILES:
            source = request.FILES.get('source')
            if not request.user.is_superuser and USE_WORKGROUPS:
                workgroups = request_workgroups(request)
            else:
                workgroups = []
            inserted = import_dispatcher(source, request.POST['type'],
                                         workgroups)
            if inserted:
                contacts_imported.send(sender=self,
                                       source=source,
                                       type=request.POST['type'])

            self.message_user(
                request,
                _('%s contacts succesfully imported.') % inserted)

        context = {
            'title': _('Contact importation'),
            '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 importation(self, request):
        """Import contacts from a VCard"""
        opts = self.model._meta

        if request.FILES:
            source = request.FILES.get('source')
            inserted = import_dispatcher(source, request.POST['type'], request_workgroups(request))
            self.message_user(request, _('%s contacts succesfully imported.') % inserted)

        context = {'title': _('Contact importation'),
                   '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))
Esempio n. 4
0
    def importation(self, request):
        """Import contacts from a VCard"""
        opts = self.model._meta

        if request.POST:
            source = request.FILES.get("source") or StringIO.StringIO(request.POST.get("source", ""))
            if not request.user.is_superuser and USE_WORKGROUPS:
                workgroups = request_workgroups(request)
            else:
                workgroups = []
            inserted = import_dispatcher(source, request.POST["type"], workgroups)
            if inserted:
                contacts_imported.send(sender=self, source=source, type=request.POST["type"])

            self.message_user(request, _("%s contacts succesfully imported.") % inserted)

        context = {"title": _("Contact importation"), "opts": opts, "app_label": opts.app_label}

        return render_to_response("newsletter/contact_import.html", context, RequestContext(request))