<s> """<STR_LIT>""" <EOL> import datetime <EOL> from django . utils . translation import ugettext_lazy as _ <EOL> from mongoengine . document import Document <EOL> from mongoengine . fields import DateTimeField , IntField , StringField <EOL> from mongoengine . queryset import QuerySetManager <EOL> from django_extensions . mongodb . fields import ( <EOL> AutoSlugField , CreationDateTimeField , ModificationDateTimeField , <EOL> ) <EOL> class TimeStampedModel ( Document ) : <EOL> """<STR_LIT>""" <EOL> created = CreationDateTimeField ( _ ( '<STR_LIT>' ) ) <EOL> modified = ModificationDateTimeField ( _ ( '<STR_LIT>' ) ) <EOL> class Meta : <EOL> abstract = True <EOL> class TitleSlugDescriptionModel ( Document ) : <EOL> """<STR_LIT>""" <EOL> title = StringField ( _ ( '<STR_LIT:title>' ) , max_length = <NUM_LIT:255> ) <EOL> slug = AutoSlugField ( _ ( '<STR_LIT>' ) , populate_from = '<STR_LIT:title>' ) <EOL> description = StringField ( _ ( '<STR_LIT:description>' ) , blank = True , null = True ) <EOL> class Meta : <EOL> abstract = True <EOL> class ActivatorModelManager ( QuerySetManager ) : <EOL> """<STR_LIT>""" <EOL> def active ( self ) : <EOL> """<STR_LIT>""" <EOL> return super ( ActivatorModelManager , self ) . get_query_set ( ) . filter ( status = <NUM_LIT:1> ) <EOL> def inactive ( self ) : <EOL> """<STR_LIT>""" <EOL> return super ( ActivatorModelManager , self ) . get_query_set ( ) . filter ( status = <NUM_LIT:0> ) <EOL> class ActivatorModel ( Document ) : <EOL> """<STR_LIT>""" <EOL> STATUS_CHOICES = ( <EOL> ( <NUM_LIT:0> , _ ( '<STR_LIT>' ) ) , <EOL> ( <NUM_LIT:1> , _ ( '<STR_LIT>' ) ) , <EOL> ) <EOL> status = IntField ( _ ( '<STR_LIT:status>' ) , choices = STATUS_CHOICES , default = <NUM_LIT:1> ) <EOL> activate_date = DateTimeField ( blank = True , null = True , help_text = _ ( '<STR_LIT>' ) ) <EOL> deactivate_date = DateTimeField ( blank = True , null = True , help_text = _ ( '<STR_LIT>' ) ) <EOL> objects = ActivatorModelManager ( ) <EOL> class Meta : <EOL> abstract = True <EOL> def save ( self , * args , ** kwargs ) : <EOL> if not self . activate_date : <EOL> self . activate_date = datetime . datetime . now ( ) <EOL> super ( ActivatorModel , self ) . save ( * args , ** kwargs ) </s>
