7

Store randomisation percentage on segment model

This commit is contained in:
Kaitlyn Crawford
2018-02-02 10:13:18 +02:00
parent 51774b939e
commit ae97118c3f

View File

@ -2,6 +2,7 @@ from __future__ import absolute_import, unicode_literals
from django import forms from django import forms
from django.conf import settings from django.conf import settings
from django.core.validators import MaxValueValidator, MinValueValidator
from django.db import models, transaction from django.db import models, transaction
from django.template.defaultfilters import slugify from django.template.defaultfilters import slugify
from django.utils.encoding import python_2_unicode_compatible from django.utils.encoding import python_2_unicode_compatible
@ -85,6 +86,16 @@ class Segment(ClusterableModel):
matched_users_count = models.PositiveIntegerField(default=0, editable=False) matched_users_count = models.PositiveIntegerField(default=0, editable=False)
matched_count_updated_at = models.DateTimeField(null=True, editable=False) matched_count_updated_at = models.DateTimeField(null=True, editable=False)
randomisation_percent = models.PositiveSmallIntegerField(
null=True, blank=True, default=None,
help_text=_(
"If this number is set each user matching the rules will "
"have this percentage chance of being placed in the segment."
), validators=[
MaxValueValidator(100),
MinValueValidator(0)
])
objects = SegmentQuerySet.as_manager() objects = SegmentQuerySet.as_manager()
base_form_class = SegmentAdminForm base_form_class = SegmentAdminForm
@ -100,6 +111,7 @@ class Segment(ClusterableModel):
FieldPanel('match_any'), FieldPanel('match_any'),
FieldPanel('type', widget=forms.RadioSelect), FieldPanel('type', widget=forms.RadioSelect),
FieldPanel('count', classname='count_field'), FieldPanel('count', classname='count_field'),
FieldPanel('randomisation_percent', classname='percent_field'),
], heading="Segment"), ], heading="Segment"),
MultiFieldPanel([ MultiFieldPanel([
InlinePanel( InlinePanel(