From f693e62bbf5873bfdabc90ffdd2c21d6b91d01a8 Mon Sep 17 00:00:00 2001
From: Paul J Stevens
Date: Wed, 31 May 2017 13:47:54 +0200
Subject: [PATCH] rename base-class to reflect mixin nature
---
sandbox/sandbox/apps/home/models.py | 4 ++--
src/wagtail_personalisation/models.py | 4 ++--
src/wagtail_personalisation/views.py | 4 ++--
src/wagtail_personalisation/wagtail_hooks.py | 6 +++---
tests/sandbox/pages/models.py | 6 +++---
5 files changed, 12 insertions(+), 12 deletions(-)
diff --git a/sandbox/sandbox/apps/home/models.py b/sandbox/sandbox/apps/home/models.py
index dd3a535..626063b 100644
--- a/sandbox/sandbox/apps/home/models.py
+++ b/sandbox/sandbox/apps/home/models.py
@@ -2,8 +2,8 @@ from __future__ import absolute_import, unicode_literals
from wagtail.wagtailcore.models import Page
-from wagtail_personalisation.models import AbstractPersonalisablePage
+from wagtail_personalisation.models import PersonalisablePageMixin
-class HomePage(AbstractPersonalisablePage, Page):
+class HomePage(PersonalisablePageMixin, Page):
pass
diff --git a/src/wagtail_personalisation/models.py b/src/wagtail_personalisation/models.py
index 9bf0cd4..546dd6e 100644
--- a/src/wagtail_personalisation/models.py
+++ b/src/wagtail_personalisation/models.py
@@ -82,7 +82,7 @@ class Segment(ClusterableModel):
return segment_rules
-class AbstractPersonalisablePage(models.Model):
+class PersonalisablePageMixin(models.Model):
"""The personalisable page model. Allows creation of variants with linked
segments.
@@ -159,4 +159,4 @@ def get_edit_handler(cls):
return edit_handler.bind_to_model(cls)
-AbstractPersonalisablePage.get_edit_handler = get_edit_handler
+PersonalisablePageMixin.get_edit_handler = get_edit_handler
diff --git a/src/wagtail_personalisation/views.py b/src/wagtail_personalisation/views.py
index 3d13602..31311ba 100644
--- a/src/wagtail_personalisation/views.py
+++ b/src/wagtail_personalisation/views.py
@@ -9,7 +9,7 @@ from wagtail.contrib.modeladmin.options import ModelAdmin, modeladmin_register
from wagtail.contrib.modeladmin.views import IndexView
from wagtail.wagtailcore.models import Page
-from wagtail_personalisation.models import AbstractPersonalisablePage, Segment
+from wagtail_personalisation.models import PersonalisablePageMixin, Segment
class SegmentModelIndexView(IndexView):
@@ -123,7 +123,7 @@ def copy_page_view(request, page_id, segment_id):
:rtype: django.http.HttpResponseRedirect
"""
- model = AbstractPersonalisablePage.get_model()
+ model = PersonalisablePageMixin.get_model()
if request.user.has_perm('wagtailadmin.access_admin'):
segment = get_object_or_404(Segment, pk=segment_id)
page = get_object_or_404(model, pk=page_id)
diff --git a/src/wagtail_personalisation/wagtail_hooks.py b/src/wagtail_personalisation/wagtail_hooks.py
index 7d5ef07..01e4e23 100644
--- a/src/wagtail_personalisation/wagtail_hooks.py
+++ b/src/wagtail_personalisation/wagtail_hooks.py
@@ -13,7 +13,7 @@ from wagtail.wagtailcore.models import Page
from wagtail_personalisation import admin_urls
from wagtail_personalisation.adapters import get_segment_adapter
-from wagtail_personalisation.models import AbstractPersonalisablePage, Segment
+from wagtail_personalisation.models import PersonalisablePageMixin, Segment
from wagtail_personalisation.utils import impersonate_other_page
logger = logging.getLogger(__name__)
@@ -109,7 +109,7 @@ def _check_for_variations(segments, page):
"""
try:
- model = AbstractPersonalisablePage.__subclasses__()[0]
+ model = PersonalisablePageMixin.__subclasses__()[0]
except IndexError:
return
for segment in segments:
@@ -156,7 +156,7 @@ def page_listing_more_buttons(page, page_perms, is_parent=False):
"""
try:
- model = AbstractPersonalisablePage.__subclasses__()[0]
+ model = PersonalisablePageMixin.__subclasses__()[0]
except IndexError:
return
segments = Segment.objects.all()
diff --git a/tests/sandbox/pages/models.py b/tests/sandbox/pages/models.py
index 1ed1e10..ef1dcd7 100644
--- a/tests/sandbox/pages/models.py
+++ b/tests/sandbox/pages/models.py
@@ -5,11 +5,11 @@ from wagtail.wagtailadmin.edit_handlers import FieldPanel
from wagtail.wagtailcore.fields import RichTextField
from wagtail.wagtailcore.models import Page
-from wagtail_personalisation.models import AbstractPersonalisablePage
+from wagtail_personalisation.models import PersonalisablePageMixin
-class HomePage(AbstractPersonalisablePage, Page):
- subtitle = models.CharField(max_length=255)
+class HomePage(PersonalisablePageMixin, Page):
+ subtitle = models.CharField(max_length=255, blank=True, default='')
body = RichTextField(blank=True, default='')
content_panels = Page.content_panels + [