def extend_import(self, itemmap): itemmap.typename = 'seantis.dir.contacts.item' itemmap.interface = IContactsDirectoryItem extended = ['street', 'zipcode', 'city', 'phone', 'fax', 'url', 'email', 'opening_hours', 'information'] itemmap.add_fields(extended, len(itemmap)) contactfields = ['first_name', 'last_name', 'street', 'zipcode', 'town', 'phone', 'fax', 'email', 'function'] contactmap = FieldMap() contactmap.interface = IContactPerson contactmap.typename = 'seantis.dir.contacts.contact' contactmap.keyfields = ('first_name', 'last_name') contactmap.add_fields(contactfields, len(itemmap)) itemmap.children.append(contactmap)
def export(self, request): fields = [ ('title', _(u'Name')), ('address', _(u'Address')), ('zipcode', _(u'Zipcode')), ('location', _(u'Location')), ('email', _(u'Email')), ('cat1', _(u'Type')), ('cat2', _(u'Location (Daycare Center)')), ('correspondence_first_name', _(u'Correspondence first name')), ('correspondence_last_name', _(u'Correspondence last name')), ('correspondence_address', _(u'Correspondence address')), ('correspondence_zipcode', _(u'Correspondence zipcode')), ('correspondence_town', _(u'Correspondence town')), ] fieldmap = FieldMap() fieldmap.root = True fieldmap.keyfields = ('title',) fieldmap.typename = 'seantis.dir.facility.item' fieldmap.add_fields(f[0] for f in fields) for field, title in fields: fieldmap.add_title(field, title) add_category_binds(fieldmap) xlsfile = StringIO() export_xls( directory=self.context, filehandle=xlsfile, language=get_current_language(self.context, request), as_template=False, fieldmap=fieldmap ) return xls_response(request, 'kitas_export_versand.xls', xlsfile)
def export(self, request): fields = [ ('title', _(u'Name')), ('affix', _(u'Name affix')), ('notes', _(u'Description')), ('spots', _(u'Total number of places')), ('address', _(u'Address')), ('zipcode', _(u'Zipcode')), ('location', _(u'Location')), ('phone', _(u'Phone')), ('email', _(u'Email')), ('url', _(u'Homepage')), ('fax', _(u'Fax')), ('cat1', _(u'Type')), ('cat2', _(u'Location (Daycare Center)')), ('age', _(u'Age')), ('cat4', _(u'Language')), ('cat3', _(u'Subsidized')), ('holidays', _(u'Holidays')), ('opening_hours', _(u'Opening Hours')), ('contact_first_name', _(u'Contact first name')), ('contact_last_name', _(u'Contact last name')), ('contact_phone', _(u'Contact phone')), ('contact_email', _(u'Contact email')), ('correspondence_first_name', _(u'Correspondence first name')), ('correspondence_last_name', _(u'Correspondence last name')), ('correspondence_address', _(u'Correspondence address')), ('correspondence_zipcode', _(u'Correspondence zipcode')), ('correspondence_town', _(u'Correspondence town')), ('latitude', _(u'Latitude')), ('longitude', _(u'Longitude')) ] fieldmap = FieldMap() fieldmap.root = True fieldmap.keyfields = ('title',) fieldmap.typename = 'seantis.dir.facility.item' fieldmap.add_fields(f[0] for f in fields) for field, title in fields: fieldmap.add_title(field, title) add_category_binds(fieldmap) to_str = lambda o: str(o) if o is not None else '' fieldmap.bind_wrapper('spots', to_str) fieldmap.bind_wrapper('latitude', to_str) fieldmap.bind_wrapper('longitude', to_str) fieldmap.bind_wrapper('notes', extract_text_from_html) xlsfile = StringIO() export_xls( directory=self.context, filehandle=xlsfile, language=get_current_language(self.context, request), as_template=False, fieldmap=fieldmap ) return xls_response(request, 'kitas_export.xls', xlsfile)