a
    ÆZEge	  ã                   @   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   úY/var/www/sistema_ama/venv/lib/python3.9/site-packages/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|i |¤Ž 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   