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

Remove page manager serialization as would require code changes to managers generated from querysets

This commit is contained in:
jacobtoppm 2020-02-13 13:46:53 +00:00 committed by Matt Westcott
parent d74aa6f448
commit 9c804c3fa3
3 changed files with 13 additions and 25 deletions

View File

@ -2,6 +2,16 @@
from django.db import migrations
from django.db.models import Count, Q
def ancestor_of_q(page):
paths = [
page.path[0:pos]
for pos in range(0, len(page.path) + 1, page.steplen)[1:]
]
q = Q(path__in=paths)
return q
def create_default_workflows(apps, schema_editor):
# This will recreate the existing publish-permission based moderation setup in the new workflow system, by creating new workflows
@ -28,7 +38,7 @@ def create_default_workflows(apps, schema_editor):
page = permission.page
page = Page.objects.get(pk=page.pk)
Page.steplen = 4
ancestors = Page.objects.ancestor_of(page)
ancestors = Page.objects.filter(ancestor_of_q(page))
ancestor_permissions = publish_permissions.filter(page__in=ancestors)
groups = Group.objects.filter(Q(page_permissions__in=ancestor_permissions) | Q(page_permissions__pk=permission.pk)).distinct()
@ -69,7 +79,7 @@ def create_default_workflows(apps, schema_editor):
class Migration(migrations.Migration):
dependencies = [
('wagtailcore', '0048_serialize_page_manager'),
('wagtailcore', '0047_add_workflow_models'),
]
operations = [

View File

@ -1,20 +0,0 @@
# Generated by Django 3.0.3 on 2020-02-12 14:34
from django.db import migrations
import wagtail.core.models
class Migration(migrations.Migration):
dependencies = [
('wagtailcore', '0046_add_workflow_models'),
]
operations = [
migrations.AlterModelManagers(
name='page',
managers=[
('objects', wagtail.core.models.PageManager()),
],
),
]

View File

@ -336,13 +336,11 @@ def get_default_page_content_type():
class BasePageManager(models.Manager):
def get_queryset(self):
return self._queryset_class(self.model).order_by('path')
class PageManager(BasePageManager.from_queryset(PageQuerySet)):
use_in_migrations = True
PageManager = BasePageManager.from_queryset(PageQuerySet)
class PageBase(models.base.ModelBase):