mirror of
https://github.com/Hopiu/wagtail.git
synced 2026-05-25 23:33:45 +00:00
Create base ReportView and refactor locked_pages into subclass LockedPagesView, with a base template base_reports.html for simple listing reports
This commit is contained in:
parent
d06e7d8462
commit
1c94a9cd53
5 changed files with 51 additions and 32 deletions
|
|
@ -0,0 +1,22 @@
|
|||
{% extends "wagtailadmin/base.html" %}
|
||||
{% load i18n wagtailadmin_tags %}
|
||||
{% block titletag %}{{ title }}{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
{% include "wagtailadmin/shared/header.html" with title=title icon=header_icon %}
|
||||
|
||||
{% with page_obj as pages %}
|
||||
<div id="page-results">
|
||||
<div class="nice-padding">
|
||||
{% if pages %}
|
||||
{% block listing %}
|
||||
{% include "wagtailadmin/pages/listing/_list_explore.html" %}
|
||||
{% endblock %}
|
||||
{% paginate pages base_url=request.path %}
|
||||
{% else %}
|
||||
<p>{% trans 'No pages available.' %}</p>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
{% endwith %}
|
||||
{% endblock %}
|
||||
|
|
@ -1,12 +1,4 @@
|
|||
{% extends "wagtailadmin/base.html" %}
|
||||
{% load i18n %}
|
||||
{% block titletag %}{% trans "Locked pages" %}{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
{% trans "Locked pages" as title %}
|
||||
{% include "wagtailadmin/shared/header.html" with title=title icon="locked" %}
|
||||
|
||||
<div id="page-results">
|
||||
{% include "wagtailadmin/reports/locked_pages_results.html" %}
|
||||
</div>
|
||||
{% extends 'wagtailadmin/reports/base_report.html' %}
|
||||
{% block listing %}
|
||||
{% include "wagtailadmin/reports/listing/_list_unlock.html" %}
|
||||
{% endblock %}
|
||||
|
|
|
|||
|
|
@ -1,11 +0,0 @@
|
|||
{% load i18n wagtailadmin_tags %}
|
||||
<div class="nice-padding">
|
||||
{% if pages %}
|
||||
{% include "wagtailadmin/reports/listing/_list_unlock.html" %}
|
||||
|
||||
{% url 'wagtailadmin_reports:locked_pages' as pagination_base_url %}
|
||||
{% paginate pages base_url=pagination_base_url %}
|
||||
{% else %}
|
||||
<p>{% trans 'No pages have been locked.' %}</p>
|
||||
{% endif %}
|
||||
</div>
|
||||
|
|
@ -4,5 +4,5 @@ from wagtail.admin.views import reports
|
|||
|
||||
app_name = 'wagtailadmin_reports'
|
||||
urlpatterns = [
|
||||
url(r'^locked/$', reports.locked_pages, name='locked_pages')
|
||||
url(r'^locked/$', reports.LockedPagesView.as_view(), name='locked_pages')
|
||||
]
|
||||
|
|
|
|||
|
|
@ -1,14 +1,30 @@
|
|||
from django.core.paginator import Paginator
|
||||
from django.shortcuts import render
|
||||
from django.utils.translation import ugettext as _
|
||||
from django.views.generic.base import TemplateResponseMixin
|
||||
from django.views.generic.list import BaseListView
|
||||
|
||||
from wagtail.core.models import UserPagePermissionsProxy
|
||||
|
||||
|
||||
def locked_pages(request):
|
||||
pages = UserPagePermissionsProxy(request.user).editable_pages().filter(locked=True)
|
||||
class ReportView(TemplateResponseMixin, BaseListView):
|
||||
header_icon = ''
|
||||
page_kwarg = 'p'
|
||||
template_name = None
|
||||
title = ''
|
||||
paginate_by = 10
|
||||
|
||||
paginator = Paginator(pages, per_page=10)
|
||||
pages = paginator.get_page(request.GET.get('p'))
|
||||
def get_context_data(self, *args, object_list=None, **kwargs):
|
||||
context = super().get_context_data(*args, object_list=object_list, **kwargs)
|
||||
context['title'] = self.title
|
||||
context['header_icon'] = self.header_icon
|
||||
return context
|
||||
|
||||
return render(request, 'wagtailadmin/reports/locked_pages.html', {
|
||||
'pages': pages,
|
||||
})
|
||||
|
||||
class LockedPagesView(ReportView):
|
||||
template_name = 'wagtailadmin/reports/locked_pages.html'
|
||||
title = _('Locked Pages')
|
||||
header_icon = 'locked'
|
||||
|
||||
def get_queryset(self):
|
||||
pages = UserPagePermissionsProxy(self.request.user).editable_pages().filter(locked=True)
|
||||
self.queryset = pages
|
||||
return super().get_queryset()
|
||||
|
|
|
|||
Loading…
Reference in a new issue