Esempio n. 1
0
 def render_to_response(self, context, **response_kwargs):
     format = self.kwargs.get('format')
     if format == 'xml':
         serializer = ViewExportSerializer(context['views'], many=True)
         xml = ViewRenderer().render(serializer.data)
         return XMLResponse(xml, name='views')
     else:
         return render_to_format(self.request, format, _('Views'), 'views/views_export.html', context)
Esempio n. 2
0
 def render_to_response(self, context, **response_kwargs):
     format = self.kwargs.get('format')
     if format == 'xml':
         serializer = OptionSetExportSerializer(context['optionsets'],
                                                many=True)
         xml = OptionSetRenderer().render(serializer.data)
         return XMLResponse(xml, name='options')
     else:
         return render_to_format(self.request, format, _('Options'),
                                 'options/options_export.html', context)
Esempio n. 3
0
 def render_to_response(self, context, **response_kwargs):
     format = self.kwargs.get('format')
     if format == 'xml':
         serializer = CatalogExportSerializer(context['catalog'])
         xml = CatalogRenderer().render([serializer.data])
         return XMLResponse(xml, name=context['catalog'].key)
     else:
         return render_to_format(self.request, format,
                                 context['catalog'].title,
                                 'questions/catalog_export.html', context)
Esempio n. 4
0
 def render_to_response(self, context, **response_kwargs):
     format = self.kwargs.get('format')
     if format == 'xml':
         serializer = AttributeExportSerializer(context['attributes'],
                                                many=True)
         xml = AttributeRenderer().render(serializer.data)
         return XMLResponse(xml, name='domain')
     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(_('Domain'), rows, delimiter)
     else:
         return render_to_format(self.request, format, _('Domain'),
                                 'domain/domain_export.html', context)
Esempio n. 5
0
 def detail_export(self, request, pk=None):
     serializer = AttributeExportSerializer(self.get_object())
     xml = AttributeRenderer().render([serializer.data])
     return XMLResponse(xml, name=self.get_object().key)
Esempio n. 6
0
 def export(self, request):
     serializer = AttributeExportSerializer(self.get_queryset(), many=True)
     xml = AttributeRenderer().render(serializer.data)
     return XMLResponse(xml, name='attributes')
Esempio n. 7
0
 def export(self, request):
     serializer = TaskExportSerializer(self.get_queryset(), many=True)
     xml = TaskRenderer().render(serializer.data)
     return XMLResponse(xml, name='tasks')
Esempio n. 8
0
 def export(self, request):
     serializer = SectionExportSerializer(self.get_queryset(), many=True)
     xml = SectionRenderer().render(serializer.data)
     return XMLResponse(xml, name='sections')
Esempio n. 9
0
 def export(self, request):
     serializer = CatalogExportSerializer(self.get_queryset(), many=True)
     xml = CatalogRenderer().render(serializer.data)
     return XMLResponse(xml, name='catalogs')
Esempio n. 10
0
 def detail_export(self, request, pk=None):
     serializer = QuestionExportSerializer(self.get_object())
     xml = QuestionRenderer().render([serializer.data])
     return XMLResponse(xml, name=self.get_object().path)
Esempio n. 11
0
 def export(self, request):
     serializer = QuestionSetExportSerializer(self.get_queryset(),
                                              many=True)
     xml = QuestionSetRenderer().render(serializer.data)
     return XMLResponse(xml, name='questionsets')
Esempio n. 12
0
 def detail_export(self, request, pk=None):
     queryset = self.get_object().get_descendants(include_self=True)
     serializer = AttributeExportSerializer(queryset, many=True)
     xml = AttributeRenderer().render(serializer.data)
     return XMLResponse(xml, name=self.get_object().key)