+
    TjR                         ^ RI HtHt ^ RIHtHt ^ RIHt ^ RIH	t	H
t
 ^ RIHtHtHtHt ^ RIHtHtHt  ! R R]4      t ! R	 R
]4      tR tR tR tR tR tR]n        R tR tR t ! R R4      tR# )    )Counterdefaultdict)partialreduce)chain)
attrgetteror_)IntegrityErrorconnectionsmodelstransaction)query_utilssignalssqlc                   2   a a ] tR t^
t oV 3R ltRtVtV ;t# )ProtectedErrorc                2   < W n         \        SV `	  W4       R # N)protected_objectssuper__init__)selfmsgr   	__class__s   &&&N/var/www/idalgo/venv/lib/python3.14/site-packages/django/db/models/deletion.pyr   ProtectedError.__init__   s    !20    )r   __name__
__module____qualname____firstlineno__r   __static_attributes____classdictcell____classcell__r   __classdict__s   @@r   r   r   
   s     1 1r   r   c                   2   a a ] tR t^t oV 3R ltRtVtV ;t# )RestrictedErrorc                2   < W n         \        SV `	  W4       R # r   )restricted_objectsr   r   )r   r   r+   r   s   &&&r   r   RestrictedError.__init__   s    "41r   )r+   r   r&   s   @@r   r)   r)      s     2 2r   r)   c                 "   V P                  VVP                  P                  VP                  VP                  R R7       VP                  '       d?   \
        V,          P                  P                  '       g   V P                  VRV4       R# R# R# )F)sourcesource_attrnullablefail_on_restrictedN)	collectremote_fieldmodelnamenullr   featurescan_defer_constraint_checksadd_field_update	collectorfieldsub_objsusings   &&&&r   CASCADEr?      ss    !!''JJ    zzz+e,55QQQ""5$9 Rzr   c           	          \        R VP                  P                  P                  : RV^ ,          P                  P                  : RVP
                  : R2V4      h)z'Cannot delete some instances of model 'z@' because they are referenced through a protected foreign key: '.')r   r3   r4   r   r   r5   r:   s   &&&&r   PROTECTrC   "   sJ    
 $$--QK!!**JJ	
 		 	r   c                     V P                  W4       V P                  VP                  P                  VP                  4       R # r   )add_restricted_objectsadd_dependencyr3   r4   r:   s   &&&&r   RESTRICTrG   /   s0    $$U5U//55u{{Cr   c                 h   a  \        S 4      '       d   V 3R  lpMV 3R lpRVn        V 3R lVn        V# )c                 8   < V P                  VS! 4       V4       R # r   r9   r;   r<   r=   r>   values   &&&&r   set_on_deleteSET.<locals>.set_on_delete7   s    &&uegx@r   c                 .   < V P                  VSV4       R # r   rJ   rK   s   &&&&r   rM   rN   <   s    &&ueX>r   Tc                     < R S 3/ 3# )zdjango.db.models.SET )rL   s   r   <lambda>SET.<locals>.<lambda>A   s    )?%2(Nr   )callablelazy_sub_objsdeconstruct)rL   rM   s   f r   SETrW   4   s/    	A
	? '+# NMr   c                 ,    V P                  VR V4       R # r   rJ   r:   s   &&&&r   SET_NULLrY   E   s    udH5r   Tc                 F    V P                  WP                  4       V4       R # r   )r9   get_defaultr:   s   &&&&r   SET_DEFAULTr\   L   s    u&7&7&98Dr   c                     R # r   rQ   r:   s   &&&&r   
DO_NOTHINGr^   P   s    r   c                 4    R  V P                  RR7       4       # )c              3      "   T FU  pVP                   '       g   K  VP                  '       d   K+  VP                  '       g   VP                  '       g   KQ  Vx  KW  	  R # 5ir   )auto_createdconcrete
one_to_oneone_to_many).0fs   & r   	<genexpr>4get_candidate_relations_to_delete.<locals>.<genexpr>X   s@      5A>> 	
"#** 	
23,,,!-- 	
5s   AAAA
AT)include_hidden)
get_fields)optss   &r   !get_candidate_relations_to_deleterl   T   s    5 r   c                      a  ] tR t^_t o RR ltRR ltRR ltR tR tR t	R t
R	 tRR
 ltR tRR ltR tR tR tR tRtV tR# )	CollectorNc                    Wn         W n        \        \        4      V n        \        \
        4      V n        \        \        \        \        4      4      V n        . V n	        \        \        4      V n
        R # r   )r>   originr   setdatalistfield_updatesr   r+   fast_deletesdependencies)r   r>   rp   s   &&&r   r   Collector.__init__`   sR    
$	(."-gk3.G"H  (,r   c                   V'       g   . # . pV^ ,          P                   pV P                  V,          pV F  pW9  g   K  VP                  V4       K  	  VP                  V4       Ve   V'       g   V P	                  W&VR7       V# )a  
Add 'objs' to the collection of objects to be deleted. If the call is
the result of a cascade, 'source' should be the model that caused it,
and 'nullable' should be set to True if the relation can be null.

Return a list of all objects that were not already collected.
reverse_dependency)r   rr   appendupdaterF   )	r   objsr.   r0   rz   new_objsr4   	instancesobjs	   &&&&&    r   addCollector.addu   s}     IQ!!IIe$	C#$  	" hBTUr   c                   V'       d   Y!r!V P                   VP                  P                  ,          P                  VP                  P                  4       V P                  P                  W P                  P                  4       4       R # r   )rv   _metaconcrete_modelr   rr   
setdefaultdefault_factory)r   r4   
dependencyrz   s   &&&&r   rF   Collector.add_dependency   s]     *:%++44599++	
 			Z)B)B)DEr   c                L    V P                   W3,          P                  V4       R# )zq
Schedule a field update. 'objs' must be a homogeneous iterable
collection of model instances (e.g. a QuerySet).
N)rt   r{   )r   r<   rL   r}   s   &&&&r   r9   Collector.add_field_update   s    
 	5<(//5r   c                    V'       d?   V^ ,          P                   pV P                  V,          V,          P                  V4       R# R# )r   N)r   r+   r|   )r   r<   r}   r4   s   &&& r   rE    Collector.add_restricted_objects   s7    G%%E##E*5188> r   c                    WP                   9   dL   V P                   V,          P                  4        UUu/ uF  w  r4W4V,
          bK  	  uppV P                   V&   R # R # u uppi r   )r+   items)r   r4   r}   r<   r   s   &&&  r   !clear_restricted_objects_from_set+Collector.clear_restricted_objects_from_set   s_    +++ %)$;$;E$B$H$H$J.$JLE t|#$J.D##E* ,.s   Ac           
        WP                   9   ds   \        TP                  V P                   V,          P                  4        UUu. uF  pV F  pVP                  NK  	  K  	  uppR 7      4      pV P                  W4       R# R# u uppi ))pk__inN)r+   rq   filtervaluespkr   )r   r4   qsr}   r   s   &&&  r   &clear_restricted_objects_from_queryset0Collector.clear_restricted_objects_from_queryset   s    +++		 %)$;$;E$B$I$I$K$KD#'C #' $K  D 225? ,s   Bc                    \         P                  P                  V4      ;'       g     \         P                  P                  V4      # r   )r   
pre_deletehas_listenerspost_delete)r   r4   s   &&r   _has_signal_listenersCollector._has_signal_listeners   s<    !!//
 6 6  ..u5	6r   c                  a S'       d!   SP                   P                  \        Jd   R# \        VR4      '       d   VP                  P
                  pM3\        VR4      '       d    \        VR4      '       d   VP
                  pMR# V P                  V4      '       d   R# VP                  p\        ;QJ dK    V3R lVP                  P                  P                  P                  4        4       F  '       d   K   RM@	  RM<! V3R lVP                  P                  P                  P                  4        4       4      ;'       d    \        ;QJ d%    R \        V4       4       F  '       d   K   RM	  RM! R \        V4       4       4      ;'       dN    \        ;QJ d&    R VP                   4       F  '       g   K   RM	  RM! R VP                   4       4      '       * # )	a  
Determine if the objects in the given queryset-like or single object
can be fast-deleted. This can be done if there are no cascades, no
parents and no signal listeners for the object class.

The 'from_field' tells where we are coming from - we need this to
determine if the objects are in fact to be deleted. Allow also
skipping parent -> child -> parent chain preventing fast delete of
the child.
Fr   r4   _raw_deletec              3   .   <"   T F
  pVS8H  x  K  	  R # 5ir   rQ   )re   link
from_fields   & r   rg   ,Collector.can_fast_delete.<locals>.<genexpr>   s      FD 
"Fs   Tc              3   n   "   T F+  pVP                   P                  P                  \        J x  K-  	  R # 5ir   )r<   r3   	on_deleter^   )re   relateds   & r   rg   r      s,      FG **44
BFs   35c              3   :   "   T F  p\        VR 4      x  K  	  R# 5i)bulk_related_objectsN)hasattr)re   r<   s   & r   rg   r      s"      !4 E#9::!4s   )r3   r   r?   r   r   r4   r   allr   parentsr   rl   anyprivate_fields)r   r}   r   r4   rk   s   &&f  r   can_fast_deleteCollector.can_fast_delete   sj    *11;;7J4!!JJ$$ET7##m(D(DJJE%%e,, {{C  //55==DDFCCC  //55==DDF    C @FCCC @F   C !%!4!4CCC !%!4!4  	
r   c                   \        \        V P                  ,          P                  P	                  W!4      ^4      p\        V4      V8  d/   \        ^ \        V4      V4       Uu. uF  pWWC,            NK  	  up# V.# u upi )zD
Return the objs in suitably sized batches for the used connection.
)maxr   r>   opsbulk_batch_sizelenrange)r   r}   fieldsconn_batch_sizeis   &&&  r   get_del_batchesCollector.get_del_batches   s     

#''77Eq
 t9& q#d)_==A ,-= 
 6Ms   #A<c	           
        V P                  V4      '       d   V P                  P                  V4       R# V P                  WW6R7      p	V	'       g   R# V	^ ,          P                  p
V'       g   V
P
                  P                  pVP
                  P                  P                  4        F\  pV'       g   K  V	 Uu. uF  p\        WP                  4      NK  	  ppV P                  VV
VP                  P                  RRRR7       K^  	  V'       g   R# \        \        4      p\        \        4      p\!        V
P
                  4       EF  pV'       d<   VP"                  P
                  P                  V
P
                  P$                  9   d   KG  VP&                  pVP                  P(                  pV\*        8X  d   Kv  VP,                  pV P                  VVR7      '       d   VV,          P                  V4       K  V P/                  V	V.4      pV F  pV P1                  VV.V4      pVP2                  P4                  '       gj   V P7                  V4      '       gS   \9        \:        P<                  ! R \!        VP
                  4       4       4      4      pVP>                  ! \A        V4      !  p\        VRR4      '       g   V'       g   K   V! V VVV PB                  4       K  	  EK  	  V'       dZ   \E        RV
PF                  : RRPK                  V4      : R
2\9        \:        P<                  ! VP                  4       4      4      4      hVPM                  4        FO  w  ppV P/                  V	V4      pV F1  pV P1                  VVV4      pV P                  P                  V4       K3  	  KQ  	  V
P
                  PN                   FG  p\Q        VR4      '       g   K  VPS                  WPB                  4      pV P                  VV
RRR7       KI  	  V'       Edv   V PT                  PM                  4        F  w  ppV PW                  VV4       K  	  V P                   F  pV PY                  VP"                  V4       K!  	  V PZ                  P                  4       '       d   \        \        4      pV PZ                  PM                  4        F^  w  ppVPM                  4        FD  w  ppV'       g   K  R	VPF                  : R
VP                  : R	2pVV;;,          V,          uu&   KF  	  K`  	  V'       dZ   \]        RV
PF                  : RRPK                  V4      : R
2\9        \:        P<                  ! VP                  4       4      4      4      hR# R# R# u upi   \D         dU   pR	TP"                  PF                  : R
TP                  : R	2pTT;;,          TPH                  ,          uu&    Rp?EK  Rp?ii ; i)a  
Add 'objs' to the collection of objects to be deleted as well as all
parent instances. 'objs' must be a homogeneous iterable collection of
model instances (e.g. a QuerySet). If 'collect_related' is True,
related objects will be handled by their respective on_delete handler.

If the call is the result of a cascade, 'source' should be the model
that caused it and 'nullable' should be set to True, if the relation
can be null.

If 'reverse_dependency' is True, 'source' will be deleted before the
current model, rather than after. (Needed for cascading to parent
models, the one case in which the cascade follows the forwards
direction of an FK rather than the reverse direction.)

If 'keep_parents' is True, data of parent model's will be not deleted.

If 'fail_on_restricted' is False, error won't be raised even if it's
prohibited to delete such objects due to RESTRICT, that defers
restricted object checking in recursive calls where the top-level call
may need to collect more objects to determine whether restricted ones
can be deleted.
Nry   FT)r.   r/   collect_relatedrz   r1   )r   c              3   \   "   T F"  pR  VP                   P                   4       x  K$  	  R# 5i)c              3   8   "   T F  qP                   x  K  	  R # 5ir   )attname)re   rfs   & r   rg   .Collector.collect.<locals>.<genexpr>.<genexpr>T  s     S2RBZZ2Rs   N)r<   foreign_related_fields)re   rels   & r   rg   $Collector.collect.<locals>.<genexpr>S  s.      ,( T#))2R2RSS(s   *,rU   rB   rA   z&Cannot delete some instances of model z= because they are referenced through protected foreign keys: z, r   )r.   r0   r1   z> because they are referenced through restricted foreign keys: )/r   ru   r{   r   r   r   r   r   r   getattrr5   r2   r3   related_namer   rs   rl   r4   all_parentsr<   r   r^   related_modelr   related_objectsqueryselect_relatedr   rq   r   from_iterableonlytupler>   r   r   r   joinr   r   r   r   rr   r   r   r+   r)   ) r   r}   r.   r0   r   r/   rz   keep_parentsr1   r~   r4   r   ptrr   parent_objsmodel_fast_deletesr   r   r<   r   r   batchesbatchr=   referenced_fieldserrorkeyrelated_fieldsr   r   r+   r   s    &&&&&&&&&                       r   r2   Collector.collect   s   D %%$$T*88(  
 %% #[[77N%++33::<3EM"NXc73#9XK"NLL#$$'$4$4$A$A(-+/+0 !  = (.'-8EG MM''66%++:Q:QQMME**44IJ&#11M##Me#DD"=188?**8eW=G //wN NN11111-@@(+++ ,'H - 3 3(, )%  (}}e4E.FGH9ou==J!$xD/ !! FV   NNII/0	 E''(9(@(@(BCD  .@-E-E-G)M>**8^DG //~uU!!((2 ! .H
 [[//Eu455 55h

KUTe  	 0  -1IIOO,=(y66}iP ->'';;BHHbI (&&--//%0%6"-1-D-D-J-J-L)M6'-||~t4/</E/Euzz"RC.s3t;3 (6 .M
 &)
 "NN II&89 E//0B0I0I0KLM	 	 & 0 a #Ol * J+0;;+?+?L)#.%2I2II..Js   8VVW/AW**W/c                "   \         P                  P                  V Uu. uF  qDP                   R2V3NK  	  up\         P                  P                  R7      pVP
                  P                  V P                  4      P                  V4      # u upi )zA
Get a QuerySet of the related model to objs via related fields.
__in)	connector)r   Qcreater5   OR_base_managerr>   r   )r   r   r   r}   related_field	predicates   &&&&  r   r   Collector.related_objects  s{      MM((FTUn]##$D)40nU!mm&& ) 
	 **00<CCINN Vs   Bc              #  p   "   V P                   P                  4        F  w  rV F  pW3x  K
  	  K  	  R # 5ir   )rr   r   )r   r4   r   r   s   &   r   instances_with_modelCollector.instances_with_model  s/      $		 1E j  ! !2s   46c                "   . p\        4       p\        V P                  4      p\        V4      \        V4      8  d   R pV F  pWQ9   d   K  V P                  P                  VP                  P                  4      pV'       d   VP                  V4      '       d   K[  VP                  V4       VP                  VP                  P                  4       RpK  	  V'       d   K  R# V Uu/ uF  qUV P                  V,          bK  	  upV n        R# u upi )FTN)rq   rs   rr   r   rv   getr   r   
differencer{   r   )r   sorted_modelsconcrete_modelsr   foundr4   rv   s   &      r   sortCollector.sort  s    %dii- 3v;.E)#0044U[[5O5OP$)@)@)Q)Q!((/#''(B(BC E   5:GH-DIIe,,-H	Hs   &Dc                   V P                   P                  4        F(  w  r\        V\        R 4      R7      V P                   V&   K*  	  V P	                  4        \        4       p\        V P                   4      ^8X  d   \        X4      ^8X  d   \        V4      ^ ,          pV P                  V4      '       d   \        P                  ! V P                  4      ;_uu_ 4        \        P                  ! X4      P                  VP                  .V P                  4      pRRR4       \!        VXP"                  P                  P$                  R4       XVP"                  P&                  V/3# \        P(                  ! V P                  RR7      ;_uu_ 4        V P+                  4        FZ  w  rVP"                  P,                  '       d   K#  \.        P0                  P3                  VVV P                  V P4                  R7       K\  	  V P6                   F[  pVP9                  V P                  R7      pV'       g   K)  W7P:                  P"                  P&                  ;;,          V,          uu&   K]  	  V P<                  P                  4        EF  w  w  rp
. p. pV
 FU  p\?        V\@        PB                  4      '       d"   VPD                  f   VPG                  V4       KD  VPI                  V4       KW  	  V'       d/   \K        \L        V4      pVPN                  ! R/ VPP                  V	/B  V'       g   K  V^ ,          PR                  p\        PT                  ! V4      pTPW                  \        V Uu0 uF  qfP                  kK  	  up4      VPP                  V	/V P                  4       EK  	  V P                   PY                  4        F  pVP[                  4        K  	  V P                   P                  4        F  w  r\        P                  ! V4      pV Uu. uF  qfP                  NK  	  ppVP                  WP                  4      pV'       d)   W1P"                  P&                  ;;,          V,          uu&   VP"                  P,                  '       d   K  V F:  p\.        P\                  P3                  VVV P                  V P4                  R7       K<  	  K  	  RRR4       V P                   P                  4        F8  w  rV F-  p\!        WAP"                  P                  P$                  R4       K/  	  K:  	  \_        VPY                  4       4      \a        V4      3#   + '       g   i     ELD; iu upi u upi   + '       g   i     L; i)r   )r   NF)r>   	savepoint)senderinstancer>   rp   )r>   rQ   )1rr   r   sortedr   r   r   r   rs   r   r   mark_for_rollback_on_errorr>   r   DeleteQuerydelete_batchr   setattrr   r   labelatomicr   ra   r   r   sendrp   ru   r   r4   rt   
isinstancer   QuerySet_result_cacher{   extendr   r	   r|   r5   r   UpdateQueryupdate_batchr   reverser   sumdict)r   r4   r   deleted_counterr   countr   r   r<   rL   instances_listupdatesr}   combined_updatesr   pk_lists   &               r   deleteCollector.delete  s    $		 1E%iZ5EFDIIe !2 			!) tyy>Q3y>Q#6Iq)H##H-- ;;DJJGGOOE2??!tzzE H %++.."8"8$?u{{00%888djjEBB"779
{{///&&++$!$"jj#{{	 ,  : ''TZZ85#HHNN$8$89UB9 ( 372D2D2J2J2L.!/I"9foo>>%33;y1I. "0 '-c7';$$++Buzz5.AB4 G--EOOE2E&&5ff56U8KTZZ# 3M, "YY--/	!!# 0 %)IIOO$5 .-67Yc66Y7**7JJ?#KK$5$56%?6{{///(++00#(%("&**#';;	 1   ) %6Y Cx !%		 1E%++.."8"8$? & !2 ?))+,d?.CCCM HGGV 6 8] CBsY   <U/U1A+U13B?U133U1+=U1(U'<BU1U,
"A&U1AU1U$	'
U11V	)rr   rv   ru   rt   rp   r+   r>   r   )NFF)F)NFTNFFT)r   r    r!   r"   r   r   rF   r9   rE   r   r   r   r   r   r2   r   r   r   r  r#   r$   )r'   s   @r   rn   rn   _   s`     -*0F6?
@6
*
X[zO!
I$VD VDr   rn   N) collectionsr   r   	functoolsr   r   	itertoolsr   operatorr   r	   	django.dbr
   r   r   r   django.db.modelsr   r   r   r   r)   r?   rC   rG   rW   rY   rU   r\   r^   rl   rn   rQ   r   r   <module>r     sw    , %  $ F F 6 61^ 12n 2	:
D
"6  E	jD jDr   