
    jg                     8   d dl mZ d dlmZ d dlmZ d dlmZm	Z	m
Z
  G d dej                        Z G d dej                        Z G d	 d
e      Z G d dej                  j                         Z G d dej$                        Z G d dej                        Zy)    )models)now)gettext_lazy)AutoSlugFieldCreationDateTimeFieldModificationDateTimeFieldc                   n     e Zd ZdZ e ed            Z e ed            Z fdZ	 G d d      Z
 xZS )TimeStampedModelz|
    TimeStampedModel

    An abstract base class model that provides self-managed "created" and
    "modified" fields.
    createdmodifiedc                 h    |j                  dt        | dd            | _        t        |   di | y )Nupdate_modifiedT )popgetattrr   supersave)selfkwargs	__class__s     V/var/www/html/Stanley/venv/lib/python3.12/site-packages/django_extensions/db/models.pyr   zTimeStampedModel.save   s1    %zz*;WTK\^b=cdv    c                       e Zd ZdZdZy)TimeStampedModel.Metar   TN)__name__
__module____qualname__get_latest_byabstractr   r   r   Metar      s    "r   r    )r   r   r   __doc__r   _r   r   r   r   r    __classcell__r   s   @r   r
   r
   	   s5     $AiL1G(:7H r   r
   c                       e Zd ZdZ ej
                   ed      d      Z ej                   ed      dd      Z	 G d d	      Z
y
)TitleDescriptionModelzm
    TitleDescriptionModel

    An abstract base class model that provides title and description fields.
    title   )
max_lengthdescriptionT)blanknullc                       e Zd ZdZy)TitleDescriptionModel.MetaTNr   r   r   r   r   r   r   r    r.   '       r   r    N)r   r   r   r!   r   	CharFieldr"   r'   	TextFieldr*   r    r   r   r   r&   r&      sF     FQwZC8E"&""1]#34dKK r   r&   c                   D    e Zd ZdZ e ed      d      Z G d d      Zy)TitleSlugDescriptionModela  
    TitleSlugDescriptionModel

    An abstract base class model that provides title and description fields
    and a self-managed "slug" field that populates from the title.

    .. note ::
        If you want to use custom "slugify" function, you could
        define ``slugify_function`` which then will be used
        in :py:class:`AutoSlugField` to slugify ``populate_from`` field.

        See :py:class:`AutoSlugField` for more details.
    slugr'   )populate_fromc                       e Zd ZdZy)TitleSlugDescriptionModel.MetaTNr/   r   r   r   r    r8   <   r0   r   r    N)r   r   r   r!   r   r"   r5   r    r   r   r   r4   r4   +   s#     6':D r   r4   c                       e Zd ZdZd Zd Zy)ActivatorQuerySetzH
    ActivatorQuerySet

    Query set that returns statused results
    c                 B    | j                  t        j                        S )z Return active query set status)filterActivatorModelACTIVE_STATUSr   s    r   activezActivatorQuerySet.activeG   s    {{.">">{??r   c                 B    | j                  t        j                        S )z Return inactive query set r<   )r>   r?   INACTIVE_STATUSrA   s    r   inactivezActivatorQuerySet.inactiveK   s    {{."@"@{AAr   N)r   r   r   r!   rB   rE   r   r   r   r:   r:   @   s    @Br   r:   c                   "    e Zd ZdZd Zd Zd Zy)ActivatorModelManagerz|
    ActivatorModelManager

    Manager to return instances of ActivatorModel: SomeModel.objects.active() / .inactive()
    c                 D    t        | j                  | j                        S )z' Use ActivatorQuerySet for all results )modelusing)r:   rI   _dbrA   s    r   get_querysetz"ActivatorModelManager.get_querysetW   s     tzzBBr   c                 >    | j                         j                         S )z
        Return active instances of ActivatorModel:

        SomeModel.objects.active(), proxy to ActivatorQuerySet.active
        )rL   rB   rA   s    r   rB   zActivatorModelManager.active[   s       "))++r   c                 >    | j                         j                         S )z
        Return inactive instances of ActivatorModel:

        SomeModel.objects.inactive(), proxy to ActivatorQuerySet.inactive
        )rL   rE   rA   s    r   rE   zActivatorModelManager.inactivec   s       "++--r   N)r   r   r   r!   rL   rB   rE   r   r   r   rG   rG   P   s    C,.r   rG   c                       e Zd ZdZdZdZe ed      fe ed      ffZ ej                   ed      ee      Z
 ej                  dd ed	      
      Z ej                  dd ed      
      Z e       Z G d d      Z fdZ xZS )r?   zh
    ActivatorModel

    An abstract base class model that provides activate and deactivate fields.
    r      InactiveActiver=   )choicesdefaultTz&keep empty for an immediate activation)r+   r,   	help_textz$keep empty for indefinite activationc                       e Zd ZdZdZy)ActivatorModel.Meta)r=   z-activate_dateTN)r   r   r   orderingr   r   r   r   r    rW      s    0r   r    c                 Z    | j                   st               | _         t        |   |i | y )N)activate_dater   r   r   )r   argsr   r   s      r   r   zActivatorModel.save   s'    !!!$Dd%f%r   )r   r   r   r!   rD   r@   r"   STATUS_CHOICESr   IntegerFieldr=   DateTimeFieldrZ   deactivate_daterG   objectsr    r   r#   r$   s   @r   r?   r?   l   s     OM 
!J-(	($N !V  8nm\F(F((t$!LtJuvM*f**DANtLuvO#%G & &r   r?   N)	django.dbr   django.utils.timezoner   django.utils.translationr   r"   django_extensions.db.fieldsr   r   r   Modelr
   r&   r4   queryQuerySetr:   ManagerrG   r?   r   r   r   <module>ri      sy     % 6 g gv|| (FLL  5 *B-- B .FNN .8&V\\ &r   