kopia lustrzana https://github.com/wagtail/wagtail
Use table component for the page type usage listing
rodzic
370973dce3
commit
bdce0a0388
|
@ -0,0 +1,3 @@
|
|||
<td {% if column.classname %}class="{{ column.classname }}"{% endif %}>
|
||||
{% include "wagtailadmin/shared/page_status_tag.html" with page=instance %}
|
||||
</td>
|
|
@ -0,0 +1,4 @@
|
|||
{% load l10n %}
|
||||
<td id="page_{{ page.pk|unlocalize }}_title" class="title" valign="top" data-listing-page-title>
|
||||
{% include "wagtailadmin/pages/listing/_page_title_explore.html" with page=instance %}
|
||||
</td>
|
|
@ -0,0 +1,5 @@
|
|||
<td {% if column.classname %}class="{{ column.classname }}"{% endif %}>
|
||||
{% if value %}
|
||||
<a href="{% url 'wagtailadmin_explore' value.id %}">{{ value.specific_deferred.get_admin_display_title }}</a>
|
||||
{% endif %}
|
||||
</td>
|
|
@ -1,7 +1,7 @@
|
|||
{% load i18n wagtailadmin_tags %}
|
||||
<div class="nice-padding">
|
||||
{% if pages %}
|
||||
{% include "wagtailadmin/pages/listing/_list_explore.html" with show_parent=1 %}
|
||||
{% component table %}
|
||||
|
||||
{% if is_paginated %}
|
||||
{% include "wagtailadmin/shared/pagination_nav.html" with items=page_obj linkurl=index_url %}
|
||||
|
|
|
@ -545,7 +545,7 @@ def paginate(context, page, base_url="", page_key="p", classname=""):
|
|||
|
||||
@register.inclusion_tag("wagtailadmin/pages/listing/_buttons.html", takes_context=True)
|
||||
def page_listing_buttons(context, page, page_perms):
|
||||
next_url = context.request.path
|
||||
next_url = context["request"].path
|
||||
button_hooks = hooks.get_hooks("register_page_listing_buttons")
|
||||
|
||||
buttons = []
|
||||
|
|
|
@ -4,17 +4,54 @@ from django.contrib.contenttypes.models import ContentType
|
|||
from django.core.exceptions import PermissionDenied
|
||||
from django.http import Http404
|
||||
from django.urls import reverse
|
||||
from django.views.generic import ListView
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
|
||||
from wagtail.admin.ui.tables import Column, DateColumn
|
||||
from wagtail.admin.views import generic
|
||||
from wagtail.admin.views.generic.base import BaseListingView
|
||||
from wagtail.models import Page
|
||||
|
||||
|
||||
class ContentTypeUseView(ListView):
|
||||
class PageTitleColumn(Column):
|
||||
cell_template_name = "wagtailadmin/pages/listing/_page_title_cell.html"
|
||||
|
||||
def get_value(self, instance):
|
||||
return None
|
||||
|
||||
def get_cell_context_data(self, instance, parent_context):
|
||||
context = super().get_cell_context_data(instance, parent_context)
|
||||
context["page_perms"] = instance.permissions_for_user(
|
||||
parent_context["request"].user
|
||||
)
|
||||
return context
|
||||
|
||||
|
||||
class ParentPageColumn(Column):
|
||||
cell_template_name = "wagtailadmin/pages/listing/_parent_page_cell.html"
|
||||
|
||||
def get_value(self, instance):
|
||||
return instance.get_parent()
|
||||
|
||||
|
||||
class PageStatusColumn(Column):
|
||||
cell_template_name = "wagtailadmin/pages/listing/_page_status_cell.html"
|
||||
|
||||
def get_value(self, instance):
|
||||
return None
|
||||
|
||||
|
||||
class ContentTypeUseView(BaseListingView):
|
||||
template_name = "wagtailadmin/pages/content_type_use.html"
|
||||
page_kwarg = "p"
|
||||
paginate_by = 50
|
||||
context_object_name = "pages"
|
||||
columns = [
|
||||
PageTitleColumn("title", label=_("Title")),
|
||||
ParentPageColumn("parent", label=_("Parent")),
|
||||
DateColumn("latest_revision_created_at", label=_("Updated"), width="12%"),
|
||||
Column("type", label=_("Type"), accessor="page_type_display_name", width="12%"),
|
||||
PageStatusColumn("status", label=_("Status"), width="12%"),
|
||||
]
|
||||
|
||||
def get(self, request, *, content_type_app_name, content_type_model_name):
|
||||
try:
|
||||
|
|
Ładowanie…
Reference in New Issue