59 lines
1.8 KiB
Python
59 lines
1.8 KiB
Python
from django.utils.translation import gettext_lazy as _
|
|
from wagtail.admin.ui.tables import BooleanColumn, DateColumn
|
|
from wagtail.admin.ui.tables.pages import PageStatusColumn, PageTitleColumn
|
|
from wagtail.admin.viewsets.pages import PageListingViewSet, PageViewSet
|
|
|
|
from dnscms.admin import ListingRedirectChooseParentView
|
|
from venues.models import VenuePage
|
|
|
|
|
|
class VenueChooseParentView(ListingRedirectChooseParentView):
|
|
listing_url_name = "venues:index"
|
|
|
|
|
|
class VenueListingMixin:
|
|
"""Shared model + columns for the standalone listing and the page explorer."""
|
|
|
|
model = VenuePage
|
|
icon = "home"
|
|
columns = [
|
|
PageTitleColumn("title", label=_("Title"), sort_key="title", classname="title"),
|
|
BooleanColumn(
|
|
"show_as_bookable",
|
|
label=_("Rentals page"),
|
|
sort_key="show_as_bookable",
|
|
width="10%",
|
|
),
|
|
BooleanColumn(
|
|
"show_in_overview",
|
|
label=_("Venue overview"),
|
|
sort_key="show_in_overview",
|
|
width="10%",
|
|
),
|
|
DateColumn(
|
|
"latest_revision_created_at",
|
|
label=_("Updated"),
|
|
sort_key="latest_revision_created_at",
|
|
width="10%",
|
|
),
|
|
PageStatusColumn("status", label=_("Status"), sort_key="live", width="10%"),
|
|
]
|
|
|
|
|
|
class VenueSidebarViewSet(VenueListingMixin, PageListingViewSet):
|
|
"""Standalone 'Venues' sidebar entry, reached independently of the page tree."""
|
|
|
|
choose_parent_view_class = VenueChooseParentView
|
|
menu_label = _("Venues")
|
|
menu_order = 4
|
|
add_to_admin_menu = True
|
|
ordering = "title"
|
|
|
|
|
|
class VenueExplorerViewSet(VenueListingMixin, PageViewSet):
|
|
"""Applies the same columns when navigating into VenueIndex via the page explorer."""
|
|
|
|
|
|
venue_sidebar_viewset = VenueSidebarViewSet("venues")
|
|
venue_explorer_viewset = VenueExplorerViewSet()
|