0
0
mirror of https://github.com/wagtail/wagtail.git synced 2024-12-01 11:41:20 +01:00

Directly use ReferenceIndex.get_references_to() in generic usage view

This makes it possible to use the view with any model instead of relying on it having a get_usage() method
This commit is contained in:
Sage Abdullah 2023-02-02 16:39:54 +00:00 committed by Matt Westcott
parent 9d28b1ea97
commit ef9f575220

View File

@ -5,7 +5,7 @@ from wagtail.admin.admin_url_finder import AdminURLFinder
from wagtail.admin.ui import tables
from wagtail.admin.utils import get_latest_str
from wagtail.admin.views.generic import BaseObjectMixin, IndexView
from wagtail.models import DraftStateMixin
from wagtail.models import DraftStateMixin, ReferenceIndex
class TitleColumn(tables.TitleColumn):
@ -28,7 +28,7 @@ class UsageView(BaseObjectMixin, IndexView):
return get_latest_str(self.object)
def get_queryset(self):
return self.object.get_usage()
return ReferenceIndex.get_references_to(self.object).group_by_source_object()
def get_columns(self):
return [