8

Splits segment dashboard view and set default table view

This commit is contained in:
Jasper Berghoef
2017-05-31 11:52:37 +02:00
committed by Michael van Tellingen
parent cc38634519
commit 45f2de62ea
28 changed files with 641 additions and 301 deletions

View File

@@ -14,6 +14,7 @@ from wagtail.wagtailcore.models import Page
from wagtail_personalisation.forms import AdminPersonalisablePageForm
from wagtail_personalisation.rules import AbstractBaseRule
from wagtail_personalisation.utils import count_active_days
@python_2_unicode_compatible
@@ -65,6 +66,10 @@ class Segment(ClusterableModel):
"""Return a string with a slug for the segment."""
return slugify(self.name.lower())
def get_active_days(self):
"""Return the amount of days the segment has been active."""
return count_active_days(self.enable_date, self.disable_date)
def get_rules(self):
"""Retrieve all rules in the segment."""
rules = AbstractBaseRule.__subclasses__()