remove customer manager again for now
This commit is contained in:
@ -1,12 +1,9 @@
|
||||
from __future__ import absolute_import, unicode_literals
|
||||
|
||||
import random
|
||||
|
||||
from django import forms
|
||||
from django.conf import settings
|
||||
from django.core.validators import MaxValueValidator, MinValueValidator
|
||||
from django.db import models, transaction
|
||||
from django.db.models import F
|
||||
from django.template.defaultfilters import slugify
|
||||
from django.utils.encoding import python_2_unicode_compatible
|
||||
from django.utils.functional import cached_property
|
||||
@ -201,16 +198,6 @@ class Segment(ClusterableModel):
|
||||
return False
|
||||
|
||||
|
||||
class PersonalisablePageManager(models.Manager):
|
||||
|
||||
def canonicals(self):
|
||||
return (
|
||||
self.filter(
|
||||
personalisable_canonical_metadata__canonical_page_id=F(
|
||||
'personalisable_canonical_metadata__variant__id'))
|
||||
)
|
||||
|
||||
|
||||
class PersonalisablePageMetadata(ClusterableModel):
|
||||
"""The personalisable page model. Allows creation of variants with linked
|
||||
segments.
|
||||
@ -231,8 +218,6 @@ class PersonalisablePageMetadata(ClusterableModel):
|
||||
on_delete=models.SET_NULL,
|
||||
null=True, blank=True)
|
||||
|
||||
objects = PersonalisablePageManager()
|
||||
|
||||
@cached_property
|
||||
def has_variants(self):
|
||||
"""Return a boolean indicating whether or not the personalisable page
|
||||
|
@ -1,5 +1,6 @@
|
||||
import time
|
||||
|
||||
from django.db.models import F
|
||||
from django.template.base import FilterExpression, kwarg_re
|
||||
from django.utils import timezone
|
||||
|
||||
@ -103,4 +104,6 @@ def exclude_variants(pages):
|
||||
:return: Queryset of pages that aren't variants
|
||||
:rtype: QuerySet
|
||||
"""
|
||||
return pages.canonicals()
|
||||
return pages.filter(
|
||||
personalisable_canonical_metadata__canonical_page_id=F(
|
||||
'personalisable_canonical_metadata__variant__id'))
|
||||
|
@ -8,6 +8,7 @@ from tests.site.pages import models
|
||||
|
||||
|
||||
class ContentPageFactory(PageFactory):
|
||||
parent = None
|
||||
title = 'Test page'
|
||||
slug = factory.LazyAttribute(lambda obj: slugify(obj.title))
|
||||
|
||||
|
@ -1,5 +1,3 @@
|
||||
from __future__ import absolute_import, unicode_literals
|
||||
|
||||
from django.db import models
|
||||
from wagtail.admin.edit_handlers import FieldPanel
|
||||
from wagtail.core.fields import RichTextField
|
||||
|
@ -5,7 +5,9 @@ import datetime
|
||||
import pytest
|
||||
|
||||
from tests.factories.segment import SegmentFactory
|
||||
from tests.factories.page import ContentPageFactory
|
||||
from wagtail_personalisation.rules import TimeRule
|
||||
from tests.site.pages import models
|
||||
|
||||
|
||||
@pytest.mark.django_db
|
||||
@ -25,3 +27,10 @@ def test_metadata_page_has_variants(segmented_page):
|
||||
canonical = segmented_page.personalisation_metadata.canonical_page
|
||||
assert canonical.personalisation_metadata.is_canonical
|
||||
assert canonical.personalisation_metadata.has_variants
|
||||
|
||||
|
||||
@pytest.mark.django_db
|
||||
def test_content_page_model():
|
||||
page = ContentPageFactory()
|
||||
qs = models.ContentPage.objects.all()
|
||||
assert page in qs
|
||||
|
Reference in New Issue
Block a user