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:
parent
d74aa6f448
commit
9c804c3fa3
@ -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 = [
|
@ -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()),
|
||||
],
|
||||
),
|
||||
]
|
@ -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):
|
||||
|
Loading…
Reference in New Issue
Block a user