8

Merge pull request #16 from LabD/feature/abstract-rules

Rules automatisch aan segment editor toevoegen
This commit is contained in:
Boris Besemer
2016-12-12 15:33:55 +01:00
committed by GitHub

View File

@@ -34,7 +34,7 @@ class AbstractBaseRule(models.Model):
return True return True
def __str__(self): def __str__(self):
return "Segmentation rule" return "Abstract segmentation rule"
class Meta: class Meta:
abstract = True abstract = True
@@ -64,7 +64,7 @@ class TimeRule(AbstractBaseRule):
return starting_time <= current_time <= ending_time return starting_time <= current_time <= ending_time
def __str__(self): def __str__(self):
return '{} - {}'.format(self.start_time, self.end_time) return 'Time Rule'
@python_2_unicode_compatible @python_2_unicode_compatible
@@ -90,7 +90,7 @@ class ReferralRule(AbstractBaseRule):
return False return False
def __str__(self): def __str__(self):
return '{}'.format(self.regex_string) return 'Referral Rule'
@python_2_unicode_compatible @python_2_unicode_compatible
@@ -148,8 +148,7 @@ class VisitCountRule(AbstractBaseRule):
return False return False
def __str__(self): def __str__(self):
operator_display = self.get_operator_display() return 'Visit count Rule'
return '{} {}'.format(operator_display, self.count)
@python_2_unicode_compatible @python_2_unicode_compatible
@@ -178,7 +177,7 @@ class QueryRule(AbstractBaseRule):
return False return False
def __str__(self): def __str__(self):
return '?{}={}'.format(self.parameter, self.value) return 'Query Rule'
@python_2_unicode_compatible @python_2_unicode_compatible
@@ -207,23 +206,14 @@ class Segment(ClusterableModel):
FieldPanel('persistent'), FieldPanel('persistent'),
]), ]),
], heading="Segment"), ], heading="Segment"),
MultiFieldPanel([ MultiFieldPanel([
InlinePanel( InlinePanel(
'personalisation_timerule_related', "{}_related".format(rule._meta.db_table),
label=_("Time rule"), min_num=0, max_num=1 label=rule.__str__,
), min_num=0,
InlinePanel( max_num=1,
'personalisation_referralrule_related', ) for rule in AbstractBaseRule.__subclasses__()
label=_("Referral rule"), min_num=0, max_num=1
),
InlinePanel(
'personalisation_visitcountrule_related',
label=_("Visit count rule"), min_num=0, max_num=1
),
InlinePanel(
'personalisation_queryrule_related',
label=_("Query rule"), min_num=0, max_num=1
),
], heading="Rules"), ], heading="Rules"),
] ]