mirror of
https://github.com/wagtail/wagtail.git
synced 2024-11-28 17:13:31 +01:00
Raise warning if there are revisions for moderation
This commit is contained in:
parent
ea6ca67ae0
commit
e7595ab91d
@ -5,11 +5,18 @@ from django.urls import reverse
|
||||
from wagtail.models import GroupPagePermission, Page
|
||||
from wagtail.test.testapp.models import SimplePage
|
||||
from wagtail.test.utils import WagtailTestUtils
|
||||
from wagtail.utils.deprecation import RemovedInWagtail60Warning
|
||||
|
||||
|
||||
class TestModerationList(WagtailTestUtils, TestCase):
|
||||
"""Test moderation list rendered by `wagtailadmin_home` view"""
|
||||
|
||||
# RemovedInWagtail60Warning
|
||||
# Remove this test class when the deprecation period for the legacy
|
||||
# moderation system ends.
|
||||
# For workflows, this has been covered in
|
||||
# wagtail.admin.tests.test_workflows.TestDashboardWithPages
|
||||
|
||||
def setUp(self):
|
||||
# Create a submitter
|
||||
submitter = self.create_user(
|
||||
@ -70,7 +77,15 @@ class TestModerationList(WagtailTestUtils, TestCase):
|
||||
self.login(moderator)
|
||||
|
||||
def get(self):
|
||||
return self.client.get(reverse("wagtailadmin_home"))
|
||||
with self.assertWarnsMessage(
|
||||
RemovedInWagtail60Warning,
|
||||
"You have pages undergoing moderation in the legacy moderation system. "
|
||||
"Complete the moderation of these pages before upgrading Wagtail. "
|
||||
"Support for the legacy moderation system will be completely removed "
|
||||
"in a future release. For more details, refer to "
|
||||
"https://docs.wagtail.org/en/stable/releases/2.10.html#move-to-new-configurable-moderation-system-workflow",
|
||||
):
|
||||
return self.client.get(reverse("wagtailadmin_home"))
|
||||
|
||||
def test_edit_page(self):
|
||||
# Login as moderator
|
||||
|
@ -1,5 +1,6 @@
|
||||
import itertools
|
||||
import re
|
||||
import warnings
|
||||
from typing import Any, Mapping, Union
|
||||
|
||||
from django.conf import settings
|
||||
@ -27,6 +28,7 @@ from wagtail.models import (
|
||||
get_default_page_content_type,
|
||||
)
|
||||
from wagtail.permission_policies.pages import PagePermissionPolicy
|
||||
from wagtail.utils.deprecation import RemovedInWagtail60Warning
|
||||
|
||||
User = get_user_model()
|
||||
|
||||
@ -100,12 +102,22 @@ class PagesForModerationPanel(Component):
|
||||
def get_context_data(self, parent_context):
|
||||
request = parent_context["request"]
|
||||
context = super().get_context_data(parent_context)
|
||||
context["page_revisions_for_moderation"] = (
|
||||
revisions = (
|
||||
PagePermissionPolicy()
|
||||
.revisions_for_moderation(request.user)
|
||||
.select_related("user")
|
||||
.order_by("-created_at")
|
||||
)
|
||||
if revisions:
|
||||
warnings.warn(
|
||||
"You have pages undergoing moderation in the legacy moderation system. "
|
||||
"Complete the moderation of these pages before upgrading Wagtail. "
|
||||
"Support for the legacy moderation system will be completely removed "
|
||||
"in a future release. For more details, refer to "
|
||||
"https://docs.wagtail.org/en/stable/releases/2.10.html#move-to-new-configurable-moderation-system-workflow",
|
||||
RemovedInWagtail60Warning,
|
||||
)
|
||||
context["page_revisions_for_moderation"] = revisions
|
||||
context["request"] = request
|
||||
context["csrf_token"] = parent_context["csrf_token"]
|
||||
return context
|
||||
|
Loading…
Reference in New Issue
Block a user