Puts the receivers in a seperate file and adds appconfig
This commit is contained in:
committed by
Michael van Tellingen
parent
9a7d41284e
commit
55da67523f
@@ -1,9 +1,7 @@
|
||||
from __future__ import absolute_import, unicode_literals
|
||||
|
||||
from django.db import models
|
||||
from django.db.models.signals import pre_save
|
||||
from django.template.defaultfilters import slugify
|
||||
from django.utils import timezone
|
||||
from django.utils.encoding import python_2_unicode_compatible
|
||||
from django.utils.functional import cached_property
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
@@ -76,25 +74,6 @@ class Segment(ClusterableModel):
|
||||
return segment_rules
|
||||
|
||||
|
||||
def check_status_change(sender, instance, *args, **kwargs):
|
||||
"""Check if the status has changed. Alter dates accordingly."""
|
||||
try:
|
||||
original_status = sender.objects.get(pk=instance.id).status
|
||||
except sender.DoesNotExist:
|
||||
original_status = ""
|
||||
|
||||
if original_status != instance.status:
|
||||
if instance.status == "enabled":
|
||||
instance.enable_date = timezone.now()
|
||||
instance.visit_count = 0
|
||||
return instance
|
||||
if instance.status == "disabled":
|
||||
instance.disable_date = timezone.now()
|
||||
|
||||
|
||||
pre_save.connect(check_status_change, sender=Segment)
|
||||
|
||||
|
||||
class PersonalisablePage(Page):
|
||||
"""The personalisable page model. Allows creation of variants with linked
|
||||
segments.
|
||||
|
Reference in New Issue
Block a user