8

make personalisedpage class abstract

This commit is contained in:
Paul J Stevens
2017-05-31 11:11:19 +02:00
committed by Michael van Tellingen
parent 59b6e7f31e
commit 66ed40f8ec
3 changed files with 27 additions and 7 deletions

View File

@@ -83,11 +83,15 @@ class Segment(ClusterableModel):
return segment_rules
class PersonalisablePage(Page):
class AbstractPersonalisablePage(models.Model):
"""The personalisable page model. Allows creation of variants with linked
segments.
"""
class Meta:
abstract = True
canonical_page = models.ForeignKey(
'self', related_name='variations', on_delete=models.SET_NULL,
blank=True, null=True
@@ -110,6 +114,14 @@ class PersonalisablePage(Page):
def __str__(self):
return "{}".format(self.title)
@classmethod
def get_model(cls):
try:
cls.__subclasses__()[0]
except IndexError:
raise Exception("Unable to find non-abstract subclass for %s" %
cls.__name)
@cached_property
def has_variations(self):
"""Return a boolean indicating whether or not the personalisable page
@@ -135,6 +147,10 @@ class PersonalisablePage(Page):
return not self.canonical_page and self.has_variations
class PersonalisablePage(AbstractPersonalisablePage, Page):
""" """
@cached_classmethod
def get_edit_handler(cls):
"""Add additional edit handlers to pages that are allowed to have