
    Dvg*                     B   d dl Z d dlmZ d dlm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 d d	lm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 d dlm Z  d Z!d Z"d Z#d Z$ G d d          Z% G d de%          Z& G d de%          Z'd Z(d Z)d Z*dS )    N)chain)apps)settings)NotRegistered)NotRelationFieldflattenget_fields_from_path)checks)FieldDoesNotExist)models)
LOOKUP_SEP)
Combinable)BaseModelFormBaseModelFormSet_get_foreign_key)engines)DjangoTemplates)import_stringc                 F    	 t          | |          S # t          $ r Y dS w xY w)zX
    issubclass() variant that doesn't raise an exception if cls isn't a
    class.
    F)
issubclass	TypeError)cls	classinfos     X/var/www/pixelcanvas.ch/venv/lib/python3.11/site-packages/django/contrib/admin/checks.py_issubclassr      s9    
#y)))   uus    
  c                     t          |           }|D ]6}	 t          |          }n# t          $ r Y w xY wt          ||          r dS 7dS )z|
    Return whether or not a dotted class path (or a subclass of that class) is
    found in a list of candidate paths.
    TF)r   ImportErrorr   )
class_pathcandidate_pathsr   pathcandidate_clss        r   _contains_subclassr"      sy    
 

#
#C  	)$//MM 	 	 	H	 }c** 	44	5s   %
22c                 p    ddl m} g }|D ]*}|                    |                    |                      +|S )Nr   	all_sites)django.contrib.admin.sitesr%   extendcheck)app_configskwargsr%   errorssites        r   check_admin_appr-   /   sN    444444F / /djj--....M    c                     ddl m} t          j        d          sg S g }d}|D ]H\  }}t          j        |          s/|                    t          j        d|z  d|z                       It          j                    D ] }t          |t                    r	|j        } n!d}|s*|                    t          j        d	d
                     nd|j        vrCt          dt          j                  r)|                    t          j        dd                     d|j        vr)|                    t          j        dd                     t!          d |D                       }|r2d|j        vr)|                    t          j        dd                     t          dt          j                  s)|                    t          j        dd                     t          dt          j                  s)|                    t          j        dd                     t          dt          j                  s*|                    t          j        ddd                      |S )!zF
    Check that the admin's dependencies are correctly installed.
    r   r$   zdjango.contrib.admin))zdjango.contrib.contenttypesi  )zdjango.contrib.authi  )zdjango.contrib.messagesi  zE'%s' must be in INSTALLED_APPS in order to use the admin application.z	admin.E%d)idNzA 'django.template.backends.django.DjangoTemplates' instance must be configured in TEMPLATES in order to use the admin application.z
admin.E403z+django.contrib.auth.context_processors.authz)django.contrib.auth.backends.ModelBackendz'django.contrib.auth.context_processors.auth' must be enabled in DjangoTemplates (TEMPLATES) if using the default auth backend in order to use the admin application.z
admin.E402z3django.contrib.messages.context_processors.messagesz'django.contrib.messages.context_processors.messages' must be enabled in DjangoTemplates (TEMPLATES) in order to use the admin application.z
admin.E404c              3   $   K   | ]}|j         V  d S N)enable_nav_sidebar).0r,   s     r   	<genexpr>z%check_dependencies.<locals>.<genexpr>{   s%      LL$d5LLLLLLr.   z*django.template.context_processors.requestz'django.template.context_processors.request' must be enabled in DjangoTemplates (TEMPLATES) in order to use the admin navigation sidebar.z
admin.W411z7django.contrib.auth.middleware.AuthenticationMiddlewarezv'django.contrib.auth.middleware.AuthenticationMiddleware' must be in MIDDLEWARE in order to use the admin application.z
admin.E408z4django.contrib.messages.middleware.MessageMiddlewarezs'django.contrib.messages.middleware.MessageMiddleware' must be in MIDDLEWARE in order to use the admin application.z
admin.E409z4django.contrib.sessions.middleware.SessionMiddlewarezs'django.contrib.sessions.middleware.SessionMiddleware' must be in MIDDLEWARE in order to use the admin application.zInsert 'django.contrib.sessions.middleware.SessionMiddleware' before 'django.contrib.auth.middleware.AuthenticationMiddleware'.z
admin.E410)hintr0   )r&   r%   r   is_installedappendr
   Errorr   all
isinstancer   enginecontext_processorsr"   r   AUTHENTICATION_BACKENDSanyWarning
MIDDLEWARE)	r*   r%   r+   app_dependenciesapp_name
error_coder<   django_templates_instancesidebar_enableds	            r   check_dependenciesrG   8   sT    544444344 	F
 !1  * ** 	MM#%-."Z/     +-- ) )fo.. 	(.%E	 %)!$ 3L  	  	
 	
 	
 	
 :,?@ @";0 @ MMJ $	     B,?@ @ MM- $	     LL)LLLLL	<,?@ @ MM* $	     A8CV  	
 	LJ  	
 	
 	
 >@S  	
 	LJ  	
 	
 	
 >@S  
 	LJQ
  
 
 
	
 	
 	
 Mr.   c                       e Zd Zd Zd Zd Zd Zd Zd Zd Z	d Z
d	 Zd
 Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd ZdS )BaseModelAdminChecksc                 (   g |                      |          |                     |          |                     |          |                     |          |                     |          |                     |          |                     |          |                     |          |                     |          | 	                    |          | 
                    |          |                     |          |                     |          S r2   )_check_autocomplete_fields_check_raw_id_fields_check_fields_check_fieldsets_check_exclude_check_form_check_filter_vertical_check_filter_horizontal_check_radio_fields_check_prepopulated_fields_check_view_on_site_url_check_ordering_check_readonly_fields)self	admin_objr*   s      r   r(   zBaseModelAdminChecks.check   s@   
,,Y77
&&y11
 	**
 ""9--	

   ++
 i((
 ((33
 **955
 %%i00
 ,,Y77
 )))44
 !!),,
 ((33
 	
r.   c                      t          j        t          t          f          st	          ddd          S t          t          j         fdt          j                  D                                 S )zV
        Check that `autocomplete_fields` is a list or tuple of model fields.
        a list or tupleautocomplete_fieldsz
admin.E036optionobjr0   c                 J    g | ]\  }}                     |d |z             S )zautocomplete_fields[%d])_check_autocomplete_fields_itemr4   index
field_namer_   rX   s      r   
<listcomp>zCBaseModelAdminChecks._check_autocomplete_fields.<locals>.<listcomp>   sL        .E: <<-F-N   r.   )r;   r\   listtuplemust_ber   from_iterable	enumeraterX   r_   s   ``r   rK   z/BaseModelAdminChecks._check_autocomplete_fields   s     #1D%=AA 	!,	    #     2;3;R1S1S	   	 	 	r.   c           	      v   	 |j         j                            |          }|j        s-t	          |t
          j                  st          d||d          S 	 |j        	                    |j
        j                   }|j        s?t          j        |j        j        dt!          |          j        d|j        d          gS nU# t"          $ rH t          j        d|j
        j         j        d	t!          |          j        d|j        d
          gcY S w xY wg S # t$          $ r t'          |||d          cY S w xY w)z
        Check that an item in `autocomplete_fields` is a ForeignKey or a
        ManyToManyField and that the item has a related ModelAdmin with
        search_fields defined.
        %a foreign key or a many-to-many fieldz
admin.E038r]   z9 must define "search_fields", because it's referenced by z.autocomplete_fields.z
admin.E040r_   r0   zAn admin for model "z+" has to be registered to be referenced by z
admin.E039z
admin.E037fieldr^   r_   r0   )model_meta	get_fieldmany_to_manyr;   r   
ForeignKeyrh   
admin_siteget_model_adminremote_fieldsearch_fieldsr
   r9   	__class____name__typer   r   refer_to_missing_field)rX   r_   rd   labelrp   related_admins         r   ra   z4BaseModelAdminChecks._check_autocomplete_fields_item   s   +	IO--j99E % j@Q.R.R ; #	    # > >u?Q?W X X %2  !. 7 @ @ @ $S		 2 2 2	 !$+	 	 	  !   LL ".4=== II...	  M'	 	 	   6 IS ! 	 	 	) CL     	s$   D $C ADDD87D8c                      t          j        t          t          f          st	          ddd          S t          t          j         fdt          j                  D                                 S )zZCheck that `raw_id_fields` only contains field names that are listed
        on the model.r[   raw_id_fieldsz
admin.E001r]   c              3   R   K   | ]!\  }}                     |d |z            V  "dS )zraw_id_fields[%d]N)_check_raw_id_fields_itemrb   s      r   r5   z<BaseModelAdminChecks._check_raw_id_fields.<locals>.<genexpr>  sZ       $ $ *z 22Z)<u)D $ $ $ $ $ $r.   )r;   r   rf   rg   rh   r   ri   rj   rk   s   ``r   rL   z)BaseModelAdminChecks._check_raw_id_fields  s     #+dE];; 	!/s|    # $ $ $ $ $ .7s7H-I-I	$ $ $    r.   c                 0   	 |j         j                            |          }|j        |k    rt	          |||d          S |j        s-t          |t          j                  st          d||d          S g S # t          $ r t	          |||d          cY S w xY w)zCheck an item of `raw_id_fields`, i.e. check that field named
        `field_name` exists in model `model` and is a ForeignKey or a
        ManyToManyField.z
admin.E002ro   rm   z
admin.E003r]   )rq   rr   rs   namer}   rt   r;   r   ru   rh   r   rX   r_   rd   r~   rp   s        r   r   z.BaseModelAdminChecks._check_raw_id_fields_item  s    
	IO--j99E zZ''-$ #	    % j@Q.R.R ; #	    	+ ! 	 	 	) CL     	s   A5 5BBc                     j         g S t          j         t          t          f          st	          ddd          S j        rt          j        dj        d          gS t          j                   }t          |          t          t          |                    k    rt          j        d	j        d
          gS t          t          j         fdj         D                                 S )zCheck that `fields` only refer to existing fields, doesn't contain
        duplicates. Check if at most one of `fields` and `fieldsets` is defined.
        Nr[   fieldsz
admin.E004r]   z,Both 'fieldsets' and 'fields' are specified.z
admin.E005rn   z2The value of 'fields' contains duplicate field(s).z
admin.E006c              3   F   K   | ]}                     |d           V  dS )r   N_check_field_spec)r4   rd   r_   rX   s     r   r5   z5BaseModelAdminChecks._check_fields.<locals>.<genexpr>Y  sI           &&sJAA           r.   )r   r;   rf   rg   rh   	fieldsetsr
   r9   rz   r   lensetr   ri   )rX   r_   r   s   `` r   rM   z"BaseModelAdminChecks._check_fields=  s    
 :ICJu66 		,X3<XXXX] 	B#    $$v;;#c&kk****H#              "%*       
 
 	
r.   c                     j         g S t          j         t          t          f          st	          ddd          S g t          t          j         fdt          j                   D                                 S )zRCheck that fieldsets is properly formatted and doesn't contain
        duplicates.Nr[   r   z
admin.E007r]   c              3   T   K   | ]"\  }}                     |d |z            V  #dS )zfieldsets[%d]N)_check_fieldsets_item)r4   rc   fieldsetr_   seen_fieldsrX   s      r   r5   z8BaseModelAdminChecks._check_fieldsets.<locals>.<genexpr>l  s[       $ $ (x ..X'> $ $ $ $ $ $r.   )r   r;   rf   rg   rh   r   ri   rj   )rX   r_   r   s   ``@r   rN   z%BaseModelAdminChecks._check_fieldsets_  s     = ICMD%=99 	!+3<    K# $ $ $ $ $ $ ,5S]+C+C	$ $ $    r.   c                 P    t          |t          t          f          st          dd          S t	          |          dk    rt          dd          S t          |d         t
                    st          dd	z  d
          S d|d         vr t          j        dz  j        d          gS t          |d         d         t          t          f          st          ddz  d          S |	                    t          |d         d                              t	          |          t	          t          |                    k    r t          j        dz  j        d          gS t          t          j         fd|d         d         D                                 S )z|Check an item of `fieldsets`, i.e. check that this is a pair of a
        set name and a dictionary containing "fields" key.r[   z
admin.E008r]      zof length 2z
admin.E009   a dictionary%s[1]z
admin.E010r   z3The value of '%s[1]' must contain the key 'fields'.z
admin.E011rn   z%s[1]['fields']z(There are duplicate field(s) in '%s[1]'.z
admin.E012c              3   L   K   | ]}                     |d z            V  dS )z%s[1]["fields"]Nr   )r4   fieldset_fieldsr~   r_   rX   s     r   r5   z=BaseModelAdminChecks._check_fieldsets_item.<locals>.<genexpr>  sP          # &&sO=NQV=VWW           r.   )r;   rf   rg   rh   r   dictr
   r9   rz   r'   r   r   r   ri   )rX   r_   r   r~   r   s   `` ` r   r   z*BaseModelAdminChecks._check_fieldsets_itemt  s    (T5M22 	,UUUUU]]a=CLQQQQHQK.. 	wCL    Xa[((IEQ#    HQK1D%=AA 	!(50	    	78A;x#899:::{s3{#3#34444>F#                '/{8'<       
 
 	
r.   c                      t          |t                    r<t          t          j         fdt          |          D                                 S                      |          S )z`fields` should be an item of `fields` or an item of
        fieldset[1]['fields'] for any `fieldset` in `fieldsets`. It should be a
        field name or a tuple of field names.c              3   V   K   | ]#\  }}                     |d |fz            V  $dS )z%s[%d]N)_check_field_spec_item)r4   rc   rd   r~   r_   rX   s      r   r5   z9BaseModelAdminChecks._check_field_spec.<locals>.<genexpr>  s]       $ $ *z //ZUEN)B $ $ $ $ $ $r.   )r;   rg   rf   r   ri   rj   r   )rX   r_   r   r~   s   `` `r   r   z&BaseModelAdminChecks._check_field_spec  s    
 fe$$ 
	C# $ $ $ $ $ $ .7v->->	$ $ $     ..sFEBBBr.   c                 (   ||j         v rg S 	 |j        j                            |          }t	          |t
          j                  r:|j        j        j        j	        s$t          j        d|d|d|j        d          gS g S # t          $ r g cY S w xY w)NThe value of '&' cannot include the ManyToManyField '>', because that field manually specifies a relationship model.
admin.E013rn   )readonly_fieldsrq   rr   rs   r;   r   ManyToManyFieldrx   throughauto_createdr
   r9   rz   r   r   s        r   r   z+BaseModelAdminChecks._check_field_spec_item  s    ,,, I	11*== uf&<==!.6<I
  6;UUJJJH !$+    I' %    			s   B BBc                 (   |j         g S t          |j         t          t          f          st	          dd|d          S t          |j                   t          t          |j                             k    rt          j        d|j	        d          gS g S )	z4Check that exclude is a sequence without duplicates.Nr[   excludez
admin.E014r]   z3The value of 'exclude' contains duplicate field(s).z
admin.E015rn   )
r   r;   rf   rg   rh   r   r   r
   r9   rz   rk   s     r   rO   z#BaseModelAdminChecks._check_exclude  s     ;ICK$77 	!)    C$4$4 5 555I#    Ir.   c                 `    t          |j        t                    st          dd|d          S g S )z)Check that form subclasses BaseModelForm.r   formz
admin.E016parentr^   r_   r0   )r   r   r   must_inherit_fromrk   s     r   rP   z BaseModelAdminChecks._check_form  s=    38]33 	$&v3<    Ir.   c                      t          j        t          t          f          st	          ddd          S t          t          j         fdt          j                  D                                 S )z8Check that filter_vertical is a sequence of field names.r[   filter_verticalz
admin.E017r]   c              3   R   K   | ]!\  }}                     |d |z            V  "dS )zfilter_vertical[%d]N_check_filter_itemrb   s      r   r5   z>BaseModelAdminChecks._check_filter_vertical.<locals>.<genexpr>  sZ       $ $ *z ++Z)>)F $ $ $ $ $ $r.   )r;   r   rf   rg   rh   r   ri   rj   rk   s   ``r   rQ   z+BaseModelAdminChecks._check_filter_vertical  s    #-e}== 	!*;    # $ $ $ $ $ .7s7J-K-K	$ $ $    r.   c                      t          j        t          t          f          st	          ddd          S t          t          j         fdt          j                  D                                 S )z:Check that filter_horizontal is a sequence of field names.r[   filter_horizontalz
admin.E018r]   c              3   R   K   | ]!\  }}                     |d |z            V  "dS )zfilter_horizontal[%d]Nr   rb   s      r   r5   z@BaseModelAdminChecks._check_filter_horizontal.<locals>.<genexpr>  sZ       $ $ *z ++Z)@5)H $ $ $ $ $ $r.   )r;   r   rf   rg   rh   r   ri   rj   rk   s   ``r   rR   z-BaseModelAdminChecks._check_filter_horizontal  s    #/$?? 	!*=3<    # $ $ $ $ $ .7s7L-M-M	$ $ $    r.   c                 h   	 |j         j                            |          }|j        rt	          |t
          j                  rt          d||d          S |j        j	        j        j
        s$t          j        d| d| d|j        d          gS g S # t          $ r t          |||d	
          cY S w xY w)zCheck one item of `filter_vertical` or `filter_horizontal`, i.e.
        check that given field exists and is a ManyToManyField.za many-to-many fieldz
admin.E020r]   r   r   r   r   rn   z
admin.E019ro   )rq   rr   rs   rt   r;   r   ManyToManyRelrh   rx   r   r   r
   r9   rz   r   r}   r   s        r   r   z'BaseModelAdminChecks._check_filter_item  s   	IO--j99E % E6;O)P)P *5cl    '/5B L/ / /&/ / /  M'    	) ! 	 	 	) CL     	s   B B10B1c                      t          j        t                    st          ddd          S t	          t          j         fdj                                        D                                 S )z*Check that `radio_fields` is a dictionary.r   radio_fieldsz
admin.E021r]   c              3      K   | ]9\  }}                     |d                               |d|z            z   V  :dS )r   zradio_fields["%s"]N)_check_radio_fields_key_check_radio_fields_valuer4   rd   valr_   rX   s      r   r5   z;BaseModelAdminChecks._check_radio_fields.<locals>.<genexpr>0  st       $ $
 (
C	 00j.QQ44S"6"C $ $ $ $ $ $r.   )r;   r   r   rh   rf   r   ri   itemsrk   s   ``r   rS   z(BaseModelAdminChecks._check_radio_fields(  s    #*D11 	~3<    # $ $ $ $ $
 ,/+;+A+A+C+C$ $ $    r.   c                    	 |j         j                            |          }t          |t          j                  s+|j        s$t          j        d|d|d|j	        d          gS g S # t          $ r t          |||d          cY S w xY w)zCheck that a key of `radio_fields` dictionary is name of existing
        field and that the field is a ForeignKey or has `choices` defined.r   ' refers to 'zT', which is not an instance of ForeignKey, and does not have a 'choices' definition.z
admin.E023rn   z
admin.E022ro   )rq   rr   rs   r;   r   ru   choicesr
   r9   rz   r   r}   r   s        r   r   z,BaseModelAdminChecks._check_radio_fields_key9  s    	IO--j99E uf&788 EM LL */


<  M'    	! ! 	 	 	) CL     	s   A( (BBc                 b    ddl m}m} |||fvr t          j        d|z  |j        d          gS g S )z3Check type of a value of `radio_fields` dictionary.r   )
HORIZONTALVERTICALzDThe value of '%s' must be either admin.HORIZONTAL or admin.VERTICAL.z
admin.E024rn   )django.contrib.admin.optionsr   r   r
   r9   rz   )rX   r_   r   r~   r   r   s         r   r   z.BaseModelAdminChecks._check_radio_fields_valueQ  sg     	FEEEEEEEz8,,,&(-.#	    Ir.   c                     t          |j                  s7t          |j        t                    st	          j        d|j        d          gS g S )NzBThe value of 'view_on_site' must be a callable or a boolean value.z
admin.E025rn   )callableview_on_siter;   boolr
   r9   rz   rk   s     r   rU   z,BaseModelAdminChecks._check_view_on_site_urlb  s[    ()) 
	*S=Mt2T2T 
	#	    Ir.   c                      t          j        t                    st          ddd          S t	          t          j         fdj                                        D                                 S )zXCheck that `prepopulated_fields` is a dictionary containing allowed
        field types.r   prepopulated_fieldsz
admin.E026r]   c              3      K   | ]9\  }}                     |d                               |d|z            z   V  :dS )r   zprepopulated_fields["%s"]N)_check_prepopulated_fields_key _check_prepopulated_fields_valuer   s      r   r5   zBBaseModelAdminChecks._check_prepopulated_fields.<locals>.<genexpr>x  s|       $ $ (
C 77Z)>  ;;S"=
"J $ $ $ $ $ $r.   )r;   r   r   rh   rf   r   ri   r   rk   s   ``r   rT   z/BaseModelAdminChecks._check_prepopulated_fieldso  s     #1488 	'<#,    # $ $ $ $ $ ,/+B+H+H+J+J$ $ $  
 
 
r.   c                 6   	 |j         j                            |          }t          |t          j        t          j        t          j        f          r$t          j	        d|d|d|j
        d          gS g S # t          $ r t          |||d          cY S w xY w)zCheck a key of `prepopulated_fields` dictionary, i.e. check that it
        is a name of existing field and the field is one of the allowed types.
        r   r   zZ', which must not be a DateTimeField, a ForeignKey, a OneToOneField, or a ManyToManyField.z
admin.E028rn   z
admin.E027ro   )rq   rr   rs   r;   r   DateTimeFieldru   r   r
   r9   rz   r   r}   r   s        r   r   z3BaseModelAdminChecks._check_prepopulated_fields_key  s    
	IO--j99E ,f.?AWX   LL /4eeZZZA  M'    	% ! 	 	 	) CL     	s   A8 8BBc                      t          |t          t          f          st          dd          S t          t	          j         fdt          |          D                                 S )zdCheck a value of `prepopulated_fields` dictionary, i.e. it's an
        iterable of existing fields.r[   z
admin.E029r]   c           	   3   X   K   | ]$\  }}                     |d |d          V  %dS )[]N)%_check_prepopulated_fields_value_item)r4   rc   subfield_namer~   r_   rX   s      r   r5   zHBaseModelAdminChecks._check_prepopulated_fields_value.<locals>.<genexpr>  sa       $ $ -} >>]uuu,E $ $ $ $ $ $r.   )r;   rf   rg   rh   r   ri   rj   )rX   r_   r   r~   s   `` `r   r   z5BaseModelAdminChecks._check_prepopulated_fields_value  s     #e}-- 
	,UUUUU# $ $ $ $ $ $ 1:#	$ $ $    r.   c                     	 |j         j                            |           g S # t          $ r t	          |||d          cY S w xY w)zYFor `prepopulated_fields` equal to {"slug": ("title",)},
        `field_name` is "title".z
admin.E030ro   )rq   rr   rs   r   r}   rX   r_   rd   r~   s       r   r   z:BaseModelAdminChecks._check_prepopulated_fields_value_item  sm    	IO%%j111 I ! 	 	 	) CL     	s   # AAc                      j         g S t          j         t          t          f          st	          ddd          S t          t          j         fdt          j                   D                                 S )z;Check that ordering refers to existing fields or is random.Nr[   orderingz
admin.E031r]   c              3   R   K   | ]!\  }}                     |d |z            V  "dS )zordering[%d]N)_check_ordering_itemrb   s      r   r5   z7BaseModelAdminChecks._check_ordering.<locals>.<genexpr>  sS       $ $)z --c:~PU?UVV$ $ $ $ $ $r.   )r   r;   rf   rg   rh   r   ri   rj   rk   s   ``r   rV   z$BaseModelAdminChecks._check_ordering  s     <ICL4-88 
	!*#,    # $ $ $ $ $-6s|-D-D$ $ $    r.   c                 ^   t          |t          t          j        f          r\t          |t          j                  s|                                }t          |j        t          j                  r|j        j        }ng S |dk    r6t          |j	                  dk    rt          j        dd|j        d          gS |dk    rg S t          |v rg S |                    d          }|dk    rg S 	 |j        j                            |           g S # t$          $ r t'          |||d	
          cY S w xY w)z0Check that `ordering` refers to existing fields.?r   z^The value of 'ordering' has the random ordering marker '?', but contains other fields as well.z2Either remove the "?", or remove the other fields.z
admin.E032)r6   r_   r0   -pkz
admin.E033ro   )r;   r   r   OrderByasc
expressionFr   r   r   r
   r9   rz   r   removeprefixrq   rr   rs   r   r}   r   s       r   r   z)BaseModelAdminChecks._check_ordering_item  sf   j:v~">?? 	j&.99 .'^^--
*/:: '27

	S\!2!2a!7!79M#    3I:%% I#0055JT!!		))*555 	 %   -$U     s   +D D,+D,c                     j         dk    rg S t          j         t          t          f          st	          ddd          S t          t          j         fdt          j                   D                                 S )z?Check that readonly_fields refers to proper attribute or field. r[   r   z
admin.E034r]   c              3   R   K   | ]!\  }}                     |d |z            V  "dS )zreadonly_fields[%d]N)_check_readonly_fields_itemrb   s      r   r5   z>BaseModelAdminChecks._check_readonly_fields.<locals>.<genexpr>  sZ       $ $ *z 44Z)>)F $ $ $ $ $ $r.   )r   r;   rf   rg   rh   r   ri   rj   rk   s   ``r   rW   z+BaseModelAdminChecks._check_readonly_fields  s     "$$IC/$?? 	!*;    # $ $ $ $ $ .7s7J-K-K	$ $ $    r.   c                 `   t          |          rg S t          ||          rg S t          |j        |          rg S 	 |j        j                            |           g S # t
          $ rF t          j        d|d|d|j        j	        d|j        j        j
        d	|j        d          gcY S w xY w)Nr   r   z-', which is not a callable, an attribute of 'z', or an attribute of ''.z
admin.E035rn   )r   hasattrrq   rr   rs   r   r
   r9   rz   r{   r~   r   s       r   r   z0BaseModelAdminChecks._check_readonly_fields_item  s    J 	IS*%% 	ISY
++ 	I	))*555" 	! %   LL "EE&JJM222IO111  M'     s   A AB-,B-N)r{   
__module____qualname__r(   rK   ra   rL   r   rM   rN   r   r   r   rO   rP   rQ   rR   r   rS   r   r   rU   rT   r   r   r   rV   r   rW   r   r   r.   r   rI   rI      s       
 
 
"  .1 1 1f  $  < 
  
  
D  **
 *
 *
XC C C"  <  (          8  "  0  "    (  6       $$ $ $L  &    r.   rI   c                        e Zd Z fdZd Zd Zd Zd Zd Zd Z	d Z
d	 Zd
 Zd Zd Zd Zd Zd Zd Zd Zd Zd Z xZS )ModelAdminChecksc                 l   g t                                          |          |                     |          |                     |          |                     |          |                     |          |                     |          |                     |          |                     |          | 	                    |          | 
                    |          |                     |          |                     |          |                     |          |                     |          S r2   )superr(   _check_save_as_check_save_on_top_check_inlines_check_list_display_check_list_display_links_check_list_filter_check_list_select_related_check_list_per_page_check_list_max_show_all_check_list_editable_check_search_fields_check_date_hierarchy_check_actions)rX   rY   r*   rz   s      r   r(   zModelAdminChecks.check$  s[   
WW]]9%%
  ++
 $$Y//
   ++	

 %%i00
 ++I66
 $$Y//
 ,,Y77
 &&y11
 **955
 &&y11
 &&y11
 ''	22
   ++
 	
r.   c                 `    t          |j        t                    st          dd|d          S g S )zCheck save_as is a boolean.	a booleansave_asz
admin.E101r]   )r;   r  r   rh   rk   s     r   r   zModelAdminChecks._check_save_as6  s4     #+t,, 	;yclSSSSIr.   c                 `    t          |j        t                    st          dd|d          S g S )zCheck save_on_top is a boolean.r  save_on_topz
admin.E102r]   )r;   r  r   rh   rk   s     r   r   z#ModelAdminChecks._check_save_on_top>  s4     #/400 	;}#,WWWWIr.   c                      t          j        t          t          f          st	          ddd          S t          t          j         fdt          j                  D                                 S )z%Check all inline model admin classes.r[   inlinesz
admin.E103r]   c              3   R   K   | ]!\  }}                     |d |z            V  "dS )zinlines[%d]N)_check_inlines_itemr4   rc   itemr_   rX   s      r   r5   z2ModelAdminChecks._check_inlines.<locals>.<genexpr>O  sR       $ $#t ,,S$8MNN$ $ $ $ $ $r.   )r;   r  rf   rg   rh   r   ri   rj   rk   s   ``r   r   zModelAdminChecks._check_inlinesF  s     #+e}55 
	!)    # $ $ $ $ $'0'='=$ $ $    r.   c                    	 |j         dz   |j        z   }n0# t          $ r# t          j        d|z  |j        d          gcY S w xY wddlm} t          ||          s t          j        d|z  |j        d          gS |j	        s t          j        d|z  |j        d          gS t          |j	        t          j                  st          d	d
|z  |d          S  ||j	        |j                                                  S )zCheck one inline model admin..z*'%s' must inherit from 'InlineModelAdmin'.z
admin.E104rn   r   )InlineModelAdminz#'%s' must have a 'model' attribute.z
admin.E105za Modelz%s.modelz
admin.E106r]   )r   r{   AttributeErrorr
   r9   rz   r   r  r   rq   r   Modelrh   rv   r(   )rX   r_   inliner~   inline_labelr  s         r   r
  z$ModelAdminChecks._check_inlines_itemU  sa   		!,s2V_DLL 	 	 	@3F#     	 	BAAAAA6#344 	=@<O#     	=9LH#    V\6<88 	=*|";    6#)S^44::<<<s    *AAc                      t          j        t          t          f          st	          ddd          S t          t          j         fdt          j                  D                                 S )zBCheck that list_display only contains fields or usable attributes.r[   list_displayz
admin.E107r]   c              3   R   K   | ]!\  }}                     |d |z            V  "dS )zlist_display[%d]N)_check_list_display_itemr  s      r   r5   z7ModelAdminChecks._check_list_display.<locals>.<genexpr>  sT       $ $#t 11#t=ORW=WXX$ $ $ $ $ $r.   )r;   r  rf   rg   rh   r   ri   rj   rk   s   ``r   r   z$ModelAdminChecks._check_list_display{  s     #*T5M:: 
	!.cl    # $ $ $ $ $'01A'B'B$ $ $    r.   c                    t          |          rg S t          ||          rg S 	 |j        j                            |          }n# t
          $ r 	 t          |j        |          }n# t          $ r~ 	 t          |j        |          d         }n^# t
          t          f$ rJ t          j        d| d| d|j        j         d|j        j        j         d	|j        d          gcY cY cY S w xY wY nw xY wY nw xY wt          |d	d
          r|j        s)|j        s"t          |dd           r2|j        j        j        r!t          j        d| d|j        d          gS g S )Nr   r   z,', which is not a callable or attribute of 'z)', or an attribute, method, or field on 'r   z
admin.E108rn   is_relationFrelz<' must not be a many-to-many field or a reverse foreign key.z
admin.E109)r   r   rq   rr   rs   r   getattrr  r	   r   r
   r9   rz   r{   r~   rt   one_to_manyr  rp   many_to_one)rX   r_   r  r~   rp   s        r   r  z)ModelAdminChecks._check_list_display_item  s   D>> 	IS$ 	I	IO--d33EE  	 	 		400!   0DAA"EEE)+;< 
 
 
:U : : : :;>=;Q: : !$	 5: : : !$+  	 	 	 	 	 	 	 	
 E	$ E=%00	#	','8	 eUD))	 /4io.I	
 ,U , , ,#	    	s`   A 
C4A&%C4&
C.1BC.AC(!C.#C4'C((C.+C4-C..C43C4c                 6    ddl m} j        g S t          j        t          t
          f          st          ddd          S j        j        |j        u r@t	          t          j
         fdt          j                  D                                 S g S )	zACheck that list_display_links is a unique subset of list_display.r   )
ModelAdminNza list, a tuple, or Nonelist_display_linksz
admin.E110r]   c              3   R   K   | ]!\  }}                     |d |z            V  "dS )zlist_display_links[%d]N)_check_list_display_links_itemrb   s      r   r5   z=ModelAdminChecks._check_list_display_links.<locals>.<genexpr>  sZ       $ $ *z 77Z)AE)I $ $ $ $ $ $r.   )r   r   r!  r;   rf   rg   rh   get_list_display__func__r   ri   rj   )rX   r_   r   s   `` r   r   z*ModelAdminChecks._check_list_display_links  s    ;;;;;;!)IC2T5MBB 	*+	    !*j.III# $ $ $ $ $ .7s7M-N-N	$ $ $     	r.   c                 `    ||j         vr$t          j        d|d|d|j        d          gS g S )Nr   r   z*', which is not defined in 'list_display'.z
admin.E111rn   )r  r
   r9   rz   r   s       r   r#  z/ModelAdminChecks._check_list_display_links_item  sQ    S---).


<#	    Ir.   c                      t          j        t          t          f          st	          ddd          S t          t          j         fdt          j                  D                                 S )Nr[   list_filterz
admin.E112r]   c              3   R   K   | ]!\  }}                     |d |z            V  "dS )zlist_filter[%d]N)_check_list_filter_itemr  s      r   r5   z6ModelAdminChecks._check_list_filter.<locals>.<genexpr>  sT       $ $#t 00d<MPU<UVV$ $ $ $ $ $r.   )r;   r(  rf   rg   rh   r   ri   rj   rk   s   ``r   r   z#ModelAdminChecks._check_list_filter  s    #/D%=99 
	!-S\    # $ $ $ $ $'0'A'A$ $ $    r.   c                 J   ddl m}m} t          |          rot	          |t
          j                  sUt          ||          st          d||d          S t          ||          r t          j        d|z  |j        d          gS g S t	          |t          t          f          r-|\  }}t          ||          st          d	d
|z  |d          S g S |}	 t          |j        |           g S # t"          t$          f$ r' t          j        d|d|d|j        d          gcY S w xY w)aG  
        Check one item of `list_filter`, i.e. check if it is one of three options:
        1. 'field' -- a basic field filter, possibly w/ relationships (e.g.
           'field__rel')
        2. ('field', SomeFieldListFilter) - a field-based list filter class
        3. SomeListFilter - a non-field list filter class
        r   )FieldListFilter
ListFilterr-  z
admin.E113r   z:The value of '%s' must not inherit from 'FieldListFilter'.z
admin.E114rn   r,  r   z
admin.E115r   r   z#', which does not refer to a Field.z
admin.E116)django.contrib.adminr,  r-  r   r;   r   Fieldr   r   r   r
   r9   rz   rg   rf   r	   rq   r   r   )rX   r_   r  r~   r,  r-  rp   list_filter_classs           r   r*  z(ModelAdminChecks._check_list_filter_item  s    	EDDDDDDDD>> /	*T6<"@"@ /	tZ00 ('3<    D/22 
LT M'	    	udm,, 	'+$E$0/BB (,"U?#	    	 E$SY666 	 %&78   LL$)EE5552M'	     s   C* *5D"!D"c                 z    t          |j        t          t          t          f          st          dd|d          S g S )z?Check that list_select_related is a boolean, a list or a tuple.za boolean, tuple or listlist_select_relatedz
admin.E117r]   )r;   r2  r   rf   rg   rh   rk   s     r   r   z+ModelAdminChecks._check_list_select_related  sJ     #1D$3FGG 	*,	    Ir.   c                 `    t          |j        t                    st          dd|d          S g S )z'Check that list_per_page is an integer.
an integerlist_per_pagez
admin.E118r]   )r;   r5  intrh   rk   s     r   r   z%ModelAdminChecks._check_list_per_page+  s@     #+S11 	_#,    Ir.   c                 `    t          |j        t                    st          dd|d          S g S )z+Check that list_max_show_all is an integer.r4  list_max_show_allz
admin.E119r]   )r;   r8  r6  rh   rk   s     r   r   z)ModelAdminChecks._check_list_max_show_all5  sA     #/55 	%8cl    Ir.   c                      t          j        t          t          f          st	          ddd          S t          t          j         fdt          j                  D                                 S )zjCheck that list_editable is a sequence of editable fields from
        list_display without first element.r[   list_editablez
admin.E120r]   c              3   R   K   | ]!\  }}                     |d |z            V  "dS )zlist_editable[%d]N)_check_list_editable_itemr  s      r   r5   z8ModelAdminChecks._check_list_editable.<locals>.<genexpr>I  sZ       $ $ $t 22T#6#> $ $ $ $ $ $r.   )r;   r:  rf   rg   rh   r   ri   rj   rk   s   ``r   r   z%ModelAdminChecks._check_list_editable?  s     #+dE];; 	!/s|    # $ $ $ $ $ (11B'C'C	$ $ $    r.   c                 F   	 |j         j                            |          }||j        vr$t	          j        d|d|d|j        d          gS |j        r)||j        v r t	          j        d|z  |j        d          gS |j        d         |k    r=|j        s6|j        /t	          j        d|d	|j        d         d
|j        d          gS |j        r|j	        r$t	          j        d|d|d|j        d          gS g S # t          $ r t          |||d          cY S w xY w)Nr   r   z,', which is not contained in 'list_display'.z
admin.E122rn   zMThe value of '%s' cannot be in both 'list_editable' and 'list_display_links'.z
admin.E123r   z0' refers to the first field in 'list_display' ('z<'), which cannot be used unless 'list_display_links' is set.z
admin.E124z+', which is not editable through the admin.z
admin.E125z
admin.E121ro   )rq   rr   rs   r  r
   r9   rz   r!  editableprimary_keyr   r}   r   s        r   r<  z*ModelAdminChecks._check_list_editable_itemQ  s   3	IO--j99E !111LL:?%%MM'	    ' #J#:P,P,PL02<=M'	     #z11. 2*6 LL #(%%)9!)<)<)<>  M'    ^ 
u'8 
LL05zzzCM'	    	c ! 	 	 	) CL     	s   D   D D c                 n    t          |j        t          t          f          st	          dd|d          S g S )z"Check search_fields is a sequence.r[   ry   z
admin.E126r]   )r;   ry   rf   rg   rh   rk   s     r   r   z%ModelAdminChecks._check_search_fields  sD     #+dE];; 	!/s|    Ir.   c                 $   |j         g S 	 t          |j        |j                   d         }|                                dvrt	          dd|d          S g S # t
          t          f$ r( t          j        d|j         z  |j	        d	
          gcY S w xY w)z?Check that date_hierarchy refers to DateField or DateTimeField.Nr  >   	DateFieldr   za DateField or DateTimeFielddate_hierarchyz
admin.E128r]   zNThe value of 'date_hierarchy' refers to '%s', which does not refer to a Field.z
admin.E127rn   )
rC  r	   rq   get_internal_typerh   r   r   r
   r9   rz   )rX   r_   rp   s      r   r   z&ModelAdminChecks._check_date_hierarchy  s     %I,SY8JKKBO **,,4RRR"6/'	    I% %&78   L57:7IJM'	     s    A 6BBc                 .   g }|                                 }|D ]}\  }}}t          |d          s|j        D ]^}d|z  }t          ||          sG|                    t	          j        |j        j        d|d|j        d|j        d                     _~t          j	        d |D                       }	|	
                                D ]K\  }}
|
d	k    r@|                    t	          j        d
|j        j        d|d|j        d                     L|S )Nallowed_permissionszhas_%s_permissionz must define a z() method for the z action.z
admin.E129rn   c              3   "   K   | ]
\  }}}|V  d S r2   r   )r4   _r   s      r   r5   z2ModelAdminChecks._check_actions.<locals>.<genexpr>  s(      #C#CZQaD#C#C#C#C#C#Cr.   r   z*__name__ attributes of actions defined in z must be unique. Name z is not unique.z
admin.E130)_get_base_actionsr   rF  r8   r
   r9   rz   r{   collectionsCounterr   )rX   r_   r+   actionsfuncr   rH  
permissionmethod_namenamescounts              r   r  zModelAdminChecks._check_actions  sq   '')) % 	 	MD$4!677 "6  
1J>sK00 MM !$ 6 6 6 + $	 !$+	 	 	    ##C#C7#C#C#CCC ;;== 	 	KD%qyyLL  M222 DD	  M'	 	 	   r.   )r{   r   r   r(   r   r   r   r
  r   r  r   r#  r   r*  r   r   r   r   r<  r   r   r  __classcell__rz   s   @r   r   r   #  sJ       
 
 
 
 
$      $= $= $=L  $ $ $L  2    9 9 9v        $4 4 4l    8( ( ( ( ( ( (r.   r   c                   F     e Zd Z fdZ fdZd Zd Zd Zd Zd Z	 xZ
S )InlineModelAdminChecksc                 X   |j         }g t                                          |          |                     ||          |                     ||          |                     |          |                     |          |                     |          |                     |          S r2   )	parent_modelr   r(   _check_relation_check_exclude_of_parent_model_check_extra_check_max_num_check_min_num_check_formset)rX   
inline_objr*   rW  rz   s       r   r(   zInlineModelAdminChecks.check  s    !.
WW]]:&&
!!*l;;
 00\JJ
 z**	

   ,,
   ,,
   ,,
 	
r.   c                 N   t                                          |          }|rg S |                     ||          rg S |j        g S t	          ||j        |j                  }|j        |j        v r3t          j	        d|j        d|j
        j        d|j        d          gS g S )Nfk_namezCannot exclude the field 'z6', because it is the foreign key to the parent model 'r   z
admin.E201rn   )r   rO   rX  r   r   rq   ra  r   r
   r9   rr   r~   rz   )rX   r_   rW  r+   fkrz   s        r   rY  z5InlineModelAdminChecks._check_exclude_of_parent_model  s     '',, 	I \22 	I;IlCIs{KKK7ck!! $*000	 #	 	 	  Ir.   c                     	 t          ||j        |j                   g S # t          $ r2}t	          j        |j        d         |j        d          gcY d }~S d }~ww xY w)Nr`  r   z
admin.E202rn   )r   rq   ra  
ValueErrorr
   r9   argsrz   )rX   r_   rW  es       r   rX  z&InlineModelAdminChecks._check_relation  s}    	\39ckJJJJ I  	Q 	Q 	QL,OOOPPPPPPP	Qs     
A'AAAc                 `    t          |j        t                    st          dd|d          S g S )zCheck that extra is an integer.r4  extraz
admin.E203r]   )r;   rh  r6  rh   rk   s     r   rZ  z#InlineModelAdminChecks._check_extra  s4     #)S)) 	<S\RRRRIr.   c                 r    |j         g S t          |j         t                    st          dd|d          S g S )z!Check that max_num is an integer.Nr4  max_numz
admin.E204r]   )rj  r;   r6  rh   rk   s     r   r[  z%InlineModelAdminChecks._check_max_num  A     ;ICK-- 	<	s|TTTTIr.   c                 r    |j         g S t          |j         t                    st          dd|d          S g S )z!Check that min_num is an integer.Nr4  min_numz
admin.E205r]   )rm  r;   r6  rh   rk   s     r   r\  z%InlineModelAdminChecks._check_min_num  rk  r.   c                 `    t          |j        t                    st          dd|d          S g S )z0Check formset is a subclass of BaseModelFormSet.r   formsetz
admin.E206r   )r   ro  r   r   rk   s     r   r]  z%InlineModelAdminChecks._check_formset(  s@     3;(899 	$))    Ir.   )r{   r   r   r(   rY  rX  rZ  r[  r\  r]  rR  rS  s   @r   rU  rU    s        

 

 

 

 

    >              r.   rU  c                 J    t          j        d|d| d|j        |          gS )Nr   z
' must be r  rn   r
   r9   rz   )r|   r^   r_   r0   s       r   rh   rh   3  s:    /5vvttt<	
 	
 	
 r.   c                 J    t          j        d|d| d|j        |          gS )Nr   z' must inherit from 'r   rn   rq  r   s       r   r   r   =  s:    ;A66666J	
 	
 	
 r.   c           	      n    t          j        d|d| d|j        j        j        d|j        |          gS )Nr   r   z', which is not a field of 'r   rn   )r
   r9   rq   rr   r~   rz   ro   s       r   r}   r}   G  sK    vvuuucio3335		
 	
 	
 r.   )+rJ  	itertoolsr   django.appsr   django.confr   django.contrib.admin.exceptionsr   django.contrib.admin.utilsr   r   r	   django.corer
   django.core.exceptionsr   	django.dbr   django.db.models.constantsr   django.db.models.expressionsr   django.forms.modelsr   r   r   django.templater   django.template.backends.djangor   django.utils.module_loadingr   r   r"   r-   rG   rI   r   rU  rh   r   r}   r   r.   r   <module>r     s5                               9 9 9 9 9 9 V V V V V V V V V V       4 4 4 4 4 4       1 1 1 1 1 1 3 3 3 3 3 3 Q Q Q Q Q Q Q Q Q Q # # # # # # ; ; ; ; ; ; 5 5 5 5 5 5    "  v v vro	 o	 o	 o	 o	 o	 o	 o	dr r r r r+ r r rjX X X X X1 X X Xv        r.   