U
    ade	                     @   s   d dl Z d dlmZ d dlmZ d dlmZmZm	Z	 d dl
mZ d dlmZmZmZ G dd deZG d	d
 d
eZG dd deZG dd deZdS )    N)gettext_lazy)Document)DateTimeFieldIntFieldStringField)QuerySetManager)AutoSlugFieldCreationDateTimeFieldModificationDateTimeFieldc                   @   s*   e Zd ZdZe Ze ZG dd dZdS )TimeStampedModelz|
    TimeStampedModel

    An abstract base class model that provides self-managed "created" and
    "modified" fields.
    c                   @   s   e Zd ZdZdS )zTimeStampedModel.MetaTN__name__
__module____qualname__Zabstract r   r   D/tmp/pip-unpacked-wheel-portabvm/django_extensions/mongodb/models.pyMeta   s   r   N)	r   r   r   __doc__r	   createdr
   modifiedr   r   r   r   r   r      s   r   c                   @   s>   e Zd ZdZeddZeddZedddZG dd	 d	Z	d
S )TitleSlugDescriptionModelz
    TitleSlugDescriptionModel

    An abstract base class model that provides title and description fields
    and a self-managed "slug" field that populates from the title.
       )
max_lengthtitle)Zpopulate_fromT)blanknullc                   @   s   e Zd ZdZdS )zTitleSlugDescriptionModel.MetaTNr   r   r   r   r   r   '   s   r   N)
r   r   r   r   r   r   r   Zslugdescriptionr   r   r   r   r   r      s
   

r   c                       s,   e Zd ZdZ fddZ fddZ  ZS )ActivatorModelManagerz|
    ActivatorModelManager

    Manager to return instances of ActivatorModel: SomeModel.objects.active() / .inactive()
    c                    s   t   jddS )z`
        Return active instances of ActivatorModel:

        SomeModel.objects.active()
           statussuperZget_querysetfilterself	__class__r   r   active2   s    zActivatorModelManager.activec                    s   t   jddS )zd
        Return inactive instances of ActivatorModel:

        SomeModel.objects.inactive()
        r   r   r!   r$   r&   r   r   inactive:   s    zActivatorModelManager.inactive)r   r   r   r   r(   r)   __classcell__r   r   r&   r   r   +   s   r   c                       s|   e Zd ZdZdedfdedffZeeddZeddedd	Z	edded
d	Z
e ZG dd dZ fddZ  ZS )ActivatorModelzh
    ActivatorModel

    An abstract base class model that provides activate and deactivate fields.
    r   ZInactiver   ZActive)choicesdefaultTz&keep empty for an immediate activation)r   r   	help_textz$keep empty for indefinite activationc                   @   s   e Zd ZdZdS )zActivatorModel.MetaTNr   r   r   r   r   r   S   s   r   c                    s$   | j stj | _ t j|| d S )N)activate_datedatetimenowr"   save)r%   argskwargsr&   r   r   r2   V   s    zActivatorModel.save)r   r   r   r   _ZSTATUS_CHOICESr   r    r   r/   Zdeactivate_dater   Zobjectsr   r2   r*   r   r   r&   r   r+   C   s   

r+   )r0   Zdjango.utils.translationr   r5   Zmongoengine.documentr   Zmongoengine.fieldsr   r   r   Zmongoengine.querysetr   Z django_extensions.mongodb.fieldsr   r	   r
   r   r   r   r+   r   r   r   r   <module>   s   