示例#1
0
def import_dispatcher(source, type_, workgroups):
    """Select importer and import contacts"""
    if type_ == 'vcard':
        return vcard_contacts_import(source, workgroups)
    elif type_ == 'text':
        return text_contacts_import(source, workgroups)
    elif type_ == 'excel':
        return excel_contacts_import(source, workgroups)
    return 0
def import_dispatcher(source, type_, workgroups):
    """Select importer and import contacts"""
    if type_ == 'vcard':
        return vcard_contacts_import(source, workgroups)
    elif type_ == 'text':
        return text_contacts_import(source, workgroups)
    elif type_ == 'excel':
        return excel_contacts_import(source, workgroups)
    return 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 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))