def determine_metadata(self, request, view): metadata = OrderedDict() dynamit = view.kwargs.get('dynamit') # metadata['name'] = view.get_view_name() metadata['description'] = view.get_view_description() # metadata['renders'] = [renderer.media_type for renderer in view.renderer_classes] # metadata['parses'] = [parser.media_type for parser in view.parser_classes] model = view.serializer_class.Meta.model metadata['panels'] = get_panels(model) metadata['title'] = model._meta.original_attrs metadata['dynamit'] = { 'user': dynamit.user.username, 'is_public': dynamit.is_public, 'can_comment': dynamit.can_comment, 'photo_gallery': dynamit.photo_gallery } metadata['entry_count'] = view.queryset.count() serializer = view.get_serializer() metadata['actions'] = self.get_serializer_info(serializer) return metadata
def list(self, request, *args, **kwargs): if self.es_failed: return super(IndexableModelMixin, self).list(request, *args, **kwargs) else: # bypass serialization queryset = self.filter_queryset(self.get_queryset()) # evaluates the query and cast it to list (why ?) page = self.paginate_queryset(queryset) data = OrderedDict([('count', queryset.count()), ('results', page)]) if queryset.facets: data['facets'] = queryset.facets if queryset.suggestions: data['suggestions'] = queryset.suggestions return Response(data)
def determine_metadata(self, request, view): metadata = OrderedDict() serializer = view.get_serializer() metadata['actions'] = self.get_serializer_info(serializer) return metadata