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

[feat] Add descendant context in publish page, and delete previously created bulk_move_choose_dest template

This commit is contained in:
Shohan 2021-06-24 16:13:20 +05:30 committed by Matt Westcott
parent 5c1046b2f0
commit d2c09ec5af
3 changed files with 8 additions and 23 deletions

View File

@ -1,20 +0,0 @@
{% extends "wagtailadmin/base.html" %}
{% load i18n wagtailadmin_tags %}
{% block titletag %}{% blocktrans count counter=num_pages %}Select a new parent page for 1 page {% plural %}Select a new parent page for {{counter}} pages{% endblocktrans %}{% endblock %}
{% block content %}
<header class="nice-padding">
<h1>
{% icon name="doc-empty-inverse" class_name="header-title-icon" %}
{% blocktrans count counter=num_pages %}
Select a new parent page for <span>1 page</span>
{% plural %}
Select a new parent page for <span>{{ counter }} pages</span>
{% endblocktrans %}
</h1>
</header>
<div class="nice-padding">
{% include "wagtailadmin/pages/listing/_list_move.html" with pages=child_pages parent_page=viewed_page %}
{% paginate child_pages base_url=pagination_base_url %}
</div>
{% endblock %}

View File

@ -85,8 +85,8 @@ class MoveBulkAction(PageBulkAction):
# register temporary hook to check for move related permissions
@hooks.register_temporarily('before_bulk_action', before_bulk_move)
def post(self, request, parent_object_id, **kwargs):
return super().post(request, parent_object_id, **kwargs)
def post(self, request):
return super().post(request)
@hooks.register('register_page_bulk_action')

View File

@ -14,9 +14,14 @@ class PublishBulkAction(PageBulkAction):
def check_perm(self, page):
return page.permissions_for_user(self.request.user).can_publish()
def object_context(self, obj):
context = super().object_context(obj)
context['draft_descendant_count'] = context['page'].get_descendants().not_live().count()
return context
def get_context_data(self, **kwargs):
context = super().get_context_data(**kwargs)
context['has_draft_descendants'] = any(map(lambda x: x['page'].get_descendants().not_live().count(), context['pages']))
context['has_draft_descendants'] = any(map(lambda x: x['draft_descendant_count'], context['pages']))
return context
def execute_action(cls, pages):