-
- def results_action(self, request, queryset):
- info = self.model._meta.app_label, self.model._meta.module_name
- if len(queryset) == 1:
- return HttpResponseRedirect(reverse("admin:%s_%s_results" % info, args=(queryset[0].pk,)))
- else:
- url = reverse("admin:%s_%s_selected_results" % info)
- return HttpResponseRedirect("%s?ids=%s" % (url, ','.join([str(item.pk) for item in queryset])))
- results_action.short_description = "View results for selected %(verbose_name_plural)s"
-
- def results_view(self, request, object_id=None, extra_context=None):
- if object_id is not None:
- object_ids = [object_id]
- else:
- object_ids = request.GET.get('ids').split(',')
-
- if object_ids is None:
- raise Http404
-
- qs = self.queryset(request).filter(pk__in=object_ids)
- opts = self.model._meta
-
- if len(object_ids) == 1:
- title = _(u"Search results for %s" % qs[0])
- else:
- title = _(u"Search results for multiple objects")
-
- context = {
- 'title': title,
- 'queryset': qs,
- 'opts': opts,
- 'root_path': self.admin_site.root_path,
- 'app_label': opts.app_label
- }
- return render_to_response(self.results_template, context, context_instance=RequestContext(request))