def render_to_response(self, context, **response_kwargs): serializer = ExportSerializer(context['project']) xmldata = XMLRenderer().render(serializer.data) response = HttpResponse(prettify_xml(xmldata), content_type="application/xml") response['Content-Disposition'] = 'filename="%s.xml"' % context[ 'project'].title return response
def render(self): serializer = ExportSerializer(self.project) xmldata = XMLRenderer().render(serializer.data) response = HttpResponse(prettify_xml(xmldata), content_type="application/xml") response[ 'Content-Disposition'] = 'filename="%s.xml"' % self.project.title return response
def render_to_response(self, context, **response_kwargs): format = self.kwargs.get('format') if format == 'xml': serializer = ExportSerializer(context['views'], many=True) xmldata = XMLRenderer().render(serializer.data) response = HttpResponse(prettify_xml(xmldata), content_type="application/xml") response['Content-Disposition'] = 'filename="views.xml"' return response else: return render_to_format(self.request, format, _('Views'), 'views/views_export.html', context)
def render_to_response(self, context, **response_kwargs): format = self.kwargs.get('format') if format == 'xml': serializer = ExportSerializer(context['catalog']) xmldata = XMLRenderer().render(serializer.data) response = HttpResponse(prettify_xml(xmldata), content_type="application/xml") response['Content-Disposition'] = 'filename="%s.xml"' % context['catalog'].key return response else: return render_to_format(self.request, format, context['catalog'].title, 'questions/catalog_export.html', context)
def render(self): response = HttpResponse(content_type='application/zip') response['Content-Disposition'] = 'filename="%s.zip"' % self.project.title zip_file = zipfile.ZipFile(response, 'w') for dataset in self.get_datasets(): xmldata = self.Renderer().render(dataset) zip_file.writestr(dataset.get('file_name'), prettify_xml(xmldata)) return response
def render_to_response(self, context, **response_kwargs): format = self.kwargs.get('format') if format == 'xml': serializer = ExportSerializer(context['attributes'], many=True) xmldata = XMLRenderer().render(serializer.data) response = HttpResponse(prettify_xml(xmldata), content_type="application/xml") response['Content-Disposition'] = 'filename="domain.xml"' return response elif format[:3] == 'csv': if format == 'csvcomma': delimiter = ',' else: delimiter = ';' rows = [] for attribute in context['attributes']: rows.append((attribute.key, attribute.comment, attribute.uri)) return render_to_csv(self.request, _('Domain'), rows, delimiter) else: return render_to_format(self.request, format, _('Domain'), 'domain/domain_export.html', context)
def render_to_response(self, context, **response_kwargs): format = self.kwargs.get('format') if format == 'xml': serializer = ExportSerializer(context['entities'], many=True) xmldata = XMLRenderer().render(serializer.data) response = HttpResponse(prettify_xml(xmldata), content_type="application/xml") response['Content-Disposition'] = 'filename="domain.xml"' return response elif format == 'csv': rows = [] for entity in context['entities']: rows.append( (_('Attribute') if entity.is_attribute else _('Entity'), _('collection') if entity.is_collection else '', entity.key, entity.comment, entity.uri, entity.attribute.value_type if entity.is_attribute else '', entity.attribute.unit if entity.is_attribute else '')) return render_to_csv(self.request, _('Domain'), rows) else: return render_to_format(self.request, format, _('Domain'), 'domain/domain_export.html', context)