Beispiel #1
0
    def get(self, request):

        header = ['userid', 'companyname', 'country',
                  'contactname', 'contactemail', 'phone', 'phone2', 'phone3',
                  'fax']
        rows = []

        user_obligations = self.get_obligations()

        persons = (
            Person.objects.filter(company__obligation__id__in=user_obligations)
            .all()
        )

        for person in persons:
            org = person.company
            account = org.account
            if account is None:
                continue
            rows.append([v.encode('utf-8') if v else '' for v in [
                account.uid,
                org.name,
                org.country.name,
                u"{p.title} {p.first_name} {p.family_name}".format(p=person),
                person.email,
                person.phone,
                person.phone2,
                person.phone3,
                person.fax,
            ]])
        xls_doc = backend.generate_excel(header, rows)
        return HttpResponse(xls_doc, content_type="application/vnd.ms-excel")
Beispiel #2
0
    def get(self, request):
        header = ['userid', 'name', 'date_registered', 'active', 'outdated',
                  'addr_street', 'addr_place1', 'addr_postalcode',
                  'addr_place2', 'country', 'vat_number', 'obligation']
        rows = []

        companies = self.get_companies()

        for company in companies:
            account = company.account
            rows.append([v.encode('utf-8') for v in [
                '' if account is None else account.uid,
                company.name,
                company.date_registered.strftime('%Y-%m-%d %H:%M:%S'),
                'on' if company.active else '',
                'on' if company.outdated else '',
                company.addr_street,
                company.addr_place1,
                company.addr_postalcode,
                company.addr_place2,
                company.country.name,
                company.vat_number or '',
                company.obligation.code if company.obligation else '',
            ]])

        xls_doc = backend.generate_excel(header, rows)
        return HttpResponse(xls_doc, content_type="application/vnd.ms-excel")