kopia lustrzana https://github.com/wagtail/wagtail
Move automatic handling of LiveStatusTagColumn to IndexViewOptionalFeaturesMixin
This allows us to avoid inspecting the index view class's list_display in the viewsets, which in turn allows us to use cached property on the view.pull/12917/head
rodzic
1bb0af7773
commit
d643be80f8
|
@ -21,7 +21,7 @@ from wagtail.admin.forms.models import WagtailAdminModelForm
|
|||
from wagtail.admin.models import EditingSession
|
||||
from wagtail.admin.templatetags.wagtailadmin_tags import user_display_name
|
||||
from wagtail.admin.ui.editing_sessions import EditingSessionsModule
|
||||
from wagtail.admin.ui.tables import TitleColumn
|
||||
from wagtail.admin.ui.tables import LiveStatusTagColumn, TitleColumn
|
||||
from wagtail.admin.utils import get_latest_str, set_query_params
|
||||
from wagtail.locks import BasicLock, ScheduledForPublishLock, WorkflowLock
|
||||
from wagtail.log_actions import log
|
||||
|
@ -224,6 +224,13 @@ class IndexViewOptionalFeaturesMixin:
|
|||
return queryset
|
||||
return super()._annotate_queryset_updated_at(queryset)
|
||||
|
||||
@cached_property
|
||||
def list_display(self):
|
||||
list_display = super().list_display.copy()
|
||||
if issubclass(self.model, DraftStateMixin):
|
||||
list_display.append(LiveStatusTagColumn())
|
||||
return list_display
|
||||
|
||||
|
||||
class CreateEditViewOptionalFeaturesMixin:
|
||||
"""
|
||||
|
|
|
@ -410,7 +410,7 @@ class ModelViewSet(ViewSet):
|
|||
(i.e. does not inherit from TranslatableMixin), then the LocaleColumn is
|
||||
excluded by the default IndexView.columns property.
|
||||
"""
|
||||
return self.index_view_class.list_display
|
||||
return self.UNDEFINED
|
||||
|
||||
@cached_property
|
||||
def list_filter(self):
|
||||
|
|
|
@ -18,7 +18,6 @@ from wagtail.admin.ui.side_panels import ChecksSidePanel, PreviewSidePanel
|
|||
from wagtail.admin.ui.tables import (
|
||||
BulkActionsCheckboxColumn,
|
||||
Column,
|
||||
LiveStatusTagColumn,
|
||||
TitleColumn,
|
||||
)
|
||||
from wagtail.admin.views import generic
|
||||
|
@ -777,13 +776,6 @@ class SnippetViewSet(ModelViewSet):
|
|||
per_page=self.chooser_per_page,
|
||||
)
|
||||
|
||||
@cached_property
|
||||
def list_display(self):
|
||||
list_display = super().list_display.copy()
|
||||
if self.draftstate_enabled:
|
||||
list_display.append(LiveStatusTagColumn())
|
||||
return list_display
|
||||
|
||||
@cached_property
|
||||
def icon(self):
|
||||
return self.get_icon()
|
||||
|
|
Ładowanie…
Reference in New Issue