def export_to_xml(people, questions_to_export, user_id, can_view_email): response = HttpResponse(content_type = "application/xml") response['Content-Disposition'] = 'attachment; filename="sc4g-people.xml"' xml = XMLBuilder('volunteers') for person in people: with xml.volunteer: xml.firstName(person.user.first_name) xml.lastName(person.user.last_name) if (can_view_email): xml.email(person.user.email) with xml.form_responses: for key, value in get_card_fields_with_icons_together(person, user_id).items(): xml.form_response(value, question=key) response.content = str(xml) return response
def export_to_xml(people, questions_to_export, user_id, can_view_email): response = HttpResponse(content_type = "application/xml") response['Content-Disposition'] = 'attachment; filename="sc4g-people.xml"' xml = XMLBuilder('volunteers') empty = "N/A" for person in people: with xml.volunteer: xml.firstName(person.user.first_name or empty) xml.lastName(person.user.last_name or empty) xml.locationDisplayName(person.location_display_name or empty) xml.zohoId(person.zoho_id or empty) if (can_view_email): xml.email(person.user.email or empty) question_response = [(key, [value for value in FormResponse.objects.filter( Q(question__display_name__iexact=key) and Q(person__pk=person.id))]) for key in questions_to_export] for key, values in question_response: with xml.question(name=key): for value in values: xml.form_response(value.value) response.content = str(xml) return response