
    Wwg                     :    d dl Z d dlmZ d dlmZ  G d de      Zy)    N)BaseCommand)LogEntryc                       e Zd ZdZd Zd Zy)Commandz*Deletes all log entries from the database.c                     |j                  dddd dd       |j                  ddd d	d
t        j                  j                         y )Nz-yz--yes
store_truez%Continue without asking confirmation.yes)actiondefaulthelpdestz-bz--before-datezBFlush all entries with a timestamp before a given date (ISO 8601).before_date)r   r   r   type)add_argumentdatetimedatefromisoformat)selfparsers     a/var/www/horilla/myenv/lib/python3.12/site-packages/auditlog/management/commands/auditlogflush.pyadd_argumentszCommand.add_arguments   sX    8 	 	
 	U,, 	 	
    c                    |d   }|d   }|Qd}|d| d}| j                   j                  |       t        d      j                         j	                         }|dk(  }|rdt
        j                  j                         }||j                  |      }|j                         \  }}	| j                   j                  d	|z         y | j                   j                  d
       y )Nr	   r   z9This action will clear all log entries from the database.z.This action will clear all log entries before z from the database.z*Are you sure you want to continue? [y/N]: y)timestamp__date__ltzDeleted %d objects.zAborted.)
stdoutwriteinputlowerstripr   objectsallfilterdelete)
r   argsoptionsanswerbeforewarning_messageresponseentriescount_s
             r   handlezCommand.handle   s    '>K  !$RSYRZZm"nKKo.BCIIKQQS  _F&&**,G!!..V.D~~'HE1KK3e;<KKj)r   N)__name__
__module____qualname__r   r   r.    r   r   r   r      s    7D
$*r   r   )r   django.core.management.baser   auditlog.modelsr   r   r2   r   r   <module>r5      s     3 $,*k ,*r   