
    +hu                     6   d dl 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)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     _/var/www/html/e360mart/e360mart_env/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,   2   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>m   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)hintr/   )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_dependenciesrF   :   s5    544444344 	F
 !1  * ** 	MM&,!)*+     
 +-- ) )fo.. 	(.%E	 %)!$ !fl 	
 
 
 	 	 	 	 :0CD D"#NPXPpqqD MM&,F  	      B0CD DMM&,)  	      LL)LLLLL 	 L0C!D !DMM&.&  	      WYaYlmm flF
 
 
 	 	 	
 TV^Vijj flF
 
 
 	 	 	
 TV^Vijj flFM
 

 

 

 
	 
	 
	 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 r1   )_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objr/   c                 J    g | ]\  }}                     |d |z             S )zautocomplete_fields[%d])_check_autocomplete_fields_itemr3   index
field_namer^   rW   s      r   
<listcomp>zCBaseModelAdminChecks._check_autocomplete_fields.<locals>.<listcomp>   sF     - - -%E: 44S*F_bgFghh- - -r-   )r:   r[   listtuplemust_ber   from_iterable	enumeraterW   r^   s   ``r   rJ   z/BaseModelAdminChecks._check_autocomplete_fields   s     #1D%=AA 	,5JPSXdeeee+ - - - - -)233J)K)K- - -     r-   c                 `   	 |j         j                            |          }|j        s-t	          |t
          j                  st          d||d          S |j        j	        
                    |j        j                   }|Et          j        d|j        j         j        dt          |          j        d|j        d	          gS |j        s?t          j        |j        j        d
t          |          j        d|j        d	          gS 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\   NzAn admin for model "z+" has to be registered to be referenced by z.autocomplete_fields.z
admin.E039r^   r/   z9 must define "search_fields", because it's referenced by z
admin.E040z
admin.E037fieldr]   r^   r/   )model_meta	get_fieldmany_to_manyr:   r   
ForeignKeyrg   
admin_site	_registrygetremote_fieldr	   r8   __name__type	__class__search_fieldsr
   refer_to_missing_field)rW   r^   rc   labelro   related_admins         r   r`   z4BaseModelAdminChecks._check_autocomplete_fields_item   s   #	IO--j99E % j@Q.R.R ; cl     N4889K9QRRM$LL ".4=== II...
  M'  
 
 #0 L *3<<< II...
  M'  
 
 IC ! 	d 	d 	d)
5cVbcccccc	ds   D D-,D-c                      t          j        t          t          f          st	          ddd          S t          t          j         fdt          j                  D                                 S )z\ Check that `raw_id_fields` only contains field names that are listed
        on the model. rZ   raw_id_fieldsz
admin.E001r\   c              3   R   K   | ]!\  }}                     |d |z            V  "dS )zraw_id_fields[%d]N)_check_raw_id_fields_itemra   s      r   r4   z<BaseModelAdminChecks._check_raw_id_fields.<locals>.<genexpr>   sT       , ,%E: ..sJ@SV[@[\\, , , , , ,r-   )r:   r   re   rf   rg   r   rh   ri   rj   s   ``r   rK   z)BaseModelAdminChecks._check_raw_id_fields   s     #+dE];; 	,_#R^____+ , , , , ,)233D)E)E, , ,     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)z Check 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.E002rn   rl   z
admin.E003r\   )rp   rq   rr   namer}   rs   r:   r   rt   rg   r
   rW   r^   rc   r~   ro   s        r   r   z.BaseModelAdminChecks._check_raw_id_fields_item   s    
	IO--j99E
 zZ''-$ #	    % j@Q.R.R FuZ]bnoooo	 ! 	d 	d 	d)
5cVbcccccc	d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 )z Check that `fields` only refer to existing fields, doesn't contain
        duplicates. Check if at most one of `fields` and `fieldsets` is defined.
        NrZ   fieldsz
admin.E004r\   z,Both 'fieldsets' and 'fields' are specified.z
admin.E005rm   z2The value of 'fields' contains duplicate field(s).z
admin.E006c              3   F   K   | ]}                     |d           V  dS )r   N_check_field_spec)r3   rc   r^   rW   s     r   r4   z5BaseModelAdminChecks._check_fields.<locals>.<genexpr>  sI       (
 (
 ""3
H==(
 (
 (
 (
 (
 (
r-   )r   r:   re   rf   rg   	fieldsetsr	   r8   r{   r   lensetr   rh   )rW   r^   r   s   `` r   rL   z"BaseModelAdminChecks._check_fields   s   
 :ICJu66 		,X3<XXXX] 	B#    $$v;;#c&kk****H#    E' (
 (
 (
 (
 (
!j(
 (
 (
 
 
   	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 )zT Check that fieldsets is properly formatted and doesn't contain
        duplicates. NrZ   r   z
admin.E007r\   c              3   T   K   | ]"\  }}                     |d |z            V  #dS )zfieldsets[%d]N)_check_fieldsets_item)r3   rb   fieldsetr^   seen_fieldsrW   s      r   r4   z8BaseModelAdminChecks._check_fieldsets.<locals>.<genexpr>)  sU       , ,#E8 **3/E:QS^__, , , , , ,r-   )r   r:   re   rf   rg   r   rh   ri   )rW   r^   r   s   ``@r   rM   z%BaseModelAdminChecks._check_fieldsets  s     = ICMD%=99 	,[cl[[[[K+ , , , , , ,'0'?'?, , ,     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. rZ   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.E011rm   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   )r3   fieldset_fieldsr~   r^   rW   s     r   r4   z=BaseModelAdminChecks._check_fieldsets_item.<locals>.<genexpr>L  sO       (
 (
 ""39JU9RSS(
 (
 (
 (
 (
 (
r-   )r:   re   rf   rg   r   dictr	   r8   r{   r&   r   r   r   rh   )rW   r^   r   r~   r   s   `` ` r   r   z*BaseModelAdminChecks._check_fieldsets_item.  s    (T5M22 	j,UUUUU]]a=CLQQQQHQK.. 	j>'E/s|\\\\Xa[((IEQ#    HQK1D%=AA 	j,5F5NTW\hiiii78A;x#899:::{s3{#3#34444>F#    E' (
 (
 (
 (
 (
 (
#+A;x#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)r3   rb   rc   r~   r^   rW   s      r   r4   z9BaseModelAdminChecks._check_field_spec.<locals>.<genexpr>W  sW       , ,%E: ++CXPU=VWW, , , , , ,r-   )r:   rf   re   r   rh   ri   r   )rW   r^   r   r~   s   `` `r   r   z&BaseModelAdminChecks._check_field_specQ  s    
 fe$$ 	C+ , , , , , ,)26):):, , ,     
 ..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 'z&' cannot include the ManyToManyField 'z>', because that field manually specifies a relationship model.z
admin.E013rm   )readonly_fieldsrp   rq   rr   r:   r   ManyToManyFieldrx   throughauto_createdr	   r8   r{   r
   r   s        r   r   z+BaseModelAdminChecks._check_field_spec_item^  s    ,,, I	11*== uf&<== !.6<I   %uujjj2 !$+    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 )	z6 Check that exclude is a sequence without duplicates. NrZ   excludez
admin.E014r\   z3The value of 'exclude' contains duplicate field(s).z
admin.E015rm   )
r   r:   re   rf   rg   r   r   r	   r8   r{   rj   s     r   rN   z#BaseModelAdminChecks._check_excludez  s     ;ICK$77 	,YCLYYYY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^   r/   )r   r   r   must_inherit_fromrj   s     r   rO   z BaseModelAdminChecks._check_form  s=    38]33 	$OF),? ? ? ? Ir-   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_vertical is a sequence of field names. rZ   filter_verticalz
admin.E017r\   c              3   R   K   | ]!\  }}                     |d |z            V  "dS )zfilter_vertical[%d]N_check_filter_itemra   s      r   r4   z>BaseModelAdminChecks._check_filter_vertical.<locals>.<genexpr>  sT       , ,%E: ''Z9NQV9VWW, , , , , ,r-   )r:   r   re   rf   rg   r   rh   ri   rj   s   ``r   rP   z+BaseModelAdminChecks._check_filter_vertical  s    #-e}== 	,5FCT`aaaa+ , , , , ,)233F)G)G, , ,     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. rZ   filter_horizontalz
admin.E018r\   c              3   R   K   | ]!\  }}                     |d |z            V  "dS )zfilter_horizontal[%d]Nr   ra   s      r   r4   z@BaseModelAdminChecks._check_filter_horizontal.<locals>.<genexpr>  sT       , ,%E: ''Z9PSX9XYY, , , , , ,r-   )r:   r   re   rf   rg   r   rh   ri   rj   s   ``r   rQ   z-BaseModelAdminChecks._check_filter_horizontal  s    #/$?? 	,5HcVbcccc+ , , , , ,)233H)I)I, , ,     r-   c                     	 |j         j                            |          }|j        st	          d||d          S g S # t
          $ r t          |||d          cY S w xY w)z Check 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\   z
admin.E019rn   )rp   rq   rr   rs   rg   r
   r}   r   s        r   r   z'BaseModelAdminChecks._check_filter_item  s    	IO--j99E % 5eQ]^^^^	 ! 	d 	d 	d)
5cVbcccccc	ds   = AA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r3   rc   valr^   rW   s      r   r4   z;BaseModelAdminChecks._check_radio_fields.<locals>.<genexpr>  sq       , , $J ,,S*nMM..sC9MPZ9Z[[\, , , , , ,r-   )r:   r   r   rg   re   r   rh   itemsrj   s   ``r   rR   z(BaseModelAdminChecks._check_radio_fields  s    #*D11 	>.cl[[[[+ , , , , , (+'7'='='?'?, , ,     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)z Check 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.E023rm   z
admin.E022rn   )rp   rq   rr   r:   r   rt   choicesr	   r8   r{   r
   r}   r   s        r   r   z,BaseModelAdminChecks._check_radio_fields_key  s    	IO--j99E uf&788 EM LL "EE:::  M'  	 	 	 ! 	d 	d 	d)
5cVbcccccc	ds   A( (BBc                 b    ddl m}m} |||fvr t          j        d|z  |j        d          gS g S )z5 Check type of a value of `radio_fields` dictionary. r   )
HORIZONTALVERTICALzDThe value of '%s' must be either admin.HORIZONTAL or admin.VERTICAL.z
admin.E024rm   )django.contrib.admin.optionsr   r   r	   r8   r{   )rW   r^   r   r~   r   r   s         r   r   z.BaseModelAdminChecks._check_radio_fields_value  sc     	FEEEEEEEz8,,,Z]bb#    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.E025rm   )callableview_on_siter:   boolr	   r8   r{   rj   s     r   rT   z,BaseModelAdminChecks._check_view_on_site_url  sY    ()) 		*S=Mt2T2T 		X#    Ir-   c                      t          j        t                    st          ddd          S t	          t          j         fdj                                        D                                 S )zZ Check 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   r4   zBBaseModelAdminChecks._check_prepopulated_fields.<locals>.<genexpr>  sr       , , $J 33CEZ[[55c3@[^h@hiij, , , , , ,r-   )r:   r   r   rg   re   r   rh   r   rj   s   ``r   rS   z/BaseModelAdminChecks._check_prepopulated_fields  s     #1488 	>2GSUabbbb+ , , , , , (+'>'D'D'F'F, , ,     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)z Check 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.E028rm   z
admin.E027rn   )rp   rq   rr   r:   r   DateTimeFieldrt   r   r	   r8   r{   r
   r}   r   s        r   r   z3BaseModelAdminChecks._check_prepopulated_fields_key   s    
	IO--j99E %&"68I6Ka!bcc 
LLRWRWRWYcYcYceM'	    	 ! 	d 	d 	d)
5cVbcccccc	ds   A8 8BBc                      t          |t          t          f          st          dd          S t          t	          j         fdt          |          D                                 S )zf Check a value of `prepopulated_fields` dictionary, i.e. it's an
        iterable of existing fields. rZ   z
admin.E029r\   c           	   3   X   K   | ]$\  }}                     |d |d          V  %dS )[]N)%_check_prepopulated_fields_value_item)r3   rb   subfield_namer~   r^   rW   s      r   r4   zHBaseModelAdminChecks._check_prepopulated_fields_value.<locals>.<genexpr>  s`       , ,(E= ::3[`[`[`bgbgbgOhii, , , , , ,r-   )r:   re   rf   rg   r   rh   ri   )rW   r^   r   r~   s   `` `r   r   z5BaseModelAdminChecks._check_prepopulated_fields_value  s     #e}-- 	,UUUUU+ , , , , , ,,5cNN, , ,     r-   c                     	 |j         j                            |           g S # t          $ r t	          |||d          cY S w xY w)z[ For `prepopulated_fields` equal to {"slug": ("title",)},
        `field_name` is "title". z
admin.E030rn   )rp   rq   rr   r
   r}   rW   r^   rc   r~   s       r   r   z:BaseModelAdminChecks._check_prepopulated_fields_value_item"  se    	IO%%j111 I ! 	d 	d 	d)
5cVbcccccc	d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. NrZ   orderingz
admin.E031r\   c              3   R   K   | ]!\  }}                     |d |z            V  "dS )zordering[%d]N)_check_ordering_itemra   s      r   r4   z7BaseModelAdminChecks._check_ordering.<locals>.<genexpr>6  sR       , ,%E: ))#z>E;QRR, , , , , ,r-   )r   r:   re   rf   rg   r   rh   ri   rj   s   ``r   rU   z$BaseModelAdminChecks._check_ordering-  s     <ICL4-88 	,ZS\ZZZZ+ , , , , ,)23<)@)@, , ,     r-   c                 r   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          r
|dd         }|d	k    rg S 	 |j        j                            |           g S # t$          $ r t'          |||d
          cY S w xY w)z2 Check 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)r5   r^   r/   -Npkz
admin.E033rn   )r:   r   r   OrderByasc
expressionFr   r   r   r	   r8   r{   r   
startswithrp   rq   rr   r
   r}   r   s       r   r   z)BaseModelAdminChecks._check_ordering_item;  so   j:v~">?? 	j&.99 .'^^--
*/:: '27

	S\!2!2a!7!79M#    3I:%% I$$S)) ,'^
T!!		))*555 	 % h h h-JuRUZfgggggghs   5D D65D6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 )zA Check that readonly_fields refers to proper attribute or field.  rZ   r   z
admin.E034r\   c              3   R   K   | ]!\  }}                     |d |z            V  "dS )zreadonly_fields[%d]N)_check_readonly_fields_itemra   s      r   r4   z>BaseModelAdminChecks._check_readonly_fields.<locals>.<genexpr>h  sT       , ,%E: 00jBWZ_B_``, , , , , ,r-   )r   r:   re   rf   rg   r   rh   ri   rj   s   ``r   rV   z+BaseModelAdminChecks._check_readonly_fields`  s     "$$IC/$?? 	,5FCT`aaaa+ , , , , ,)233F)G)G, , ,     r-   c           
      Z   t          |          rg S t          ||          rg S t          |j        |          rg S 	 |j        j                            |           g S # t
          $ rC t          j        d|d|j        j	        d|j        j        j
        d|j        d          gcY S w xY w)Nr   z&' is not a callable, an attribute of 'z', or an attribute of ''.z
admin.E035rm   )r   hasattrrp   rq   rr   r
   r	   r8   r{   ry   r~   r   s       r   r   z0BaseModelAdminChecks._check_readonly_fields_itemm  s    J 	IS*%% 	ISY
++ 	I	))*555 	 % 
 
 
LL "EE3=#9#9#939?;P;P;P  M'  	 	 	 	
s   A A
B*)B*N)ry   
__module____qualname__r'   rJ   r`   rK   r   rL   rM   r   r   r   rN   rO   rP   rQ   r   rR   r   r   rT   rS   r   r   r   rU   r   rV   r   r   r-   r   rH   rH      s       
 
 
"
 
 
) ) )V
 
 
  .  @  ! ! !FC C C  8  $        	 	 	  .   
 
 

 
 
  ,
 
 
	 	 	  # # #J      r-   rH   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d Z xZS )ModelAdminChecksc                    g t                                          |          |                     |          |                     |          |                     |          |                     |          |                     |          |                     |          |                     |          | 	                    |          | 
                    |          |                     |          |                     |          |                     |          |                     |          |                     |          S r1   )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_action_permission_methods_check_actions_uniqueness)rW   rX   r)   r{   s      r   r'   zModelAdminChecks.check  ss   
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
 229==
 ++I66
 	
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   rg   rj   s     r   r   zModelAdminChecks._check_save_as  s?     #+t,, 	;y"|5 5 5 5 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   rg   rj   s     r   r   z#ModelAdminChecks._check_save_on_top  s?     #/400 	;}"|5 5 5 5 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. rZ   inlinesz
admin.E103r\   c              3   R   K   | ]!\  }}                     |d |z            V  "dS )zinlines[%d]N)_check_inlines_itemr3   rb   itemr^   rW   s      r   r4   z2ModelAdminChecks._check_inlines.<locals>.<genexpr>  sR       , ,E4 ((dME4IJJ, , , , , ,r-   )r:   r  re   rf   rg   r   rh   ri   rj   s   ``r   r   zModelAdminChecks._check_inlines  s     #+e}55 	,YCLYYYY+ , , , , ,#,S[#9#9, , ,     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.E104rm   r   )InlineModelAdminz#'%s' must have a 'model' attribute.z
admin.E105za Modelz%s.modelz
admin.E106r\   )r   ry   AttributeErrorr	   r8   r{   r   r  r   rp   r   Modelrg   ru   r'   )rW   r^   inliner~   inline_labelr  s         r   r  z$ModelAdminChecks._check_inlines_item  sW   		!,s2V_DLL 	 	 	@3F#     	 	BAAAAA6#344 	=@<O#     	=9LH#    V\6<88 	=9Z,-FCT`aaaa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 )zL Check that list_display only contains fields or usable attributes.
        rZ   list_displayz
admin.E107r\   c              3   R   K   | ]!\  }}                     |d |z            V  "dS )zlist_display[%d]N)_check_list_display_itemr  s      r   r4   z7ModelAdminChecks._check_list_display.<locals>.<genexpr>  sS       , ,E4 --c49Ke9STT, , , , , ,r-   )r:   r  re   rf   rg   r   rh   ri   rj   s   ``r   r   z$ModelAdminChecks._check_list_display  s     #*T5M:: 	,^Q]^^^^+ , , , , ,#,S-=#>#>, , ,     r-   c                    t          |          rg S t          ||          rg S 	 |j        j                            |          }n|# t
          $ ro 	 t          |j        |          }nU# t          $ rH t          j	        d|d|d|j
        j        d|j        j        j        d	|j
        d          gcY cY S w xY wY nw xY wt          |t          j                  r t          j	        d|z  |j
        d	          gS g S )
Nr   r   z-', which is not a callable, an attribute of 'z!', or an attribute or method on 'r   z
admin.E108rm   z0The value of '%s' must not be a ManyToManyField.z
admin.E109)r   r   rp   rq   rr   r
   getattrr  r	   r8   r{   ry   r~   r:   r   r   )rW   r^   r	  r~   ro   s        r   r  z)ModelAdminChecks._check_list_display_item  sZ   D>> 	IS$ 	I	IO--d33EE  	 	 		400!   LL "EE444)?)?)?IO111	  M'	 	 	      	  eV344 	FN#    	s6   A 
B>A&%B>&AB83B>7B88B>=B>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 )	zK Check 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_itemra   s      r   r4   z=ModelAdminChecks._check_list_display_links.<locals>.<genexpr>  sT       , ,%E: 33CE]`eEeff, , , , , ,r-   )r   r  r  r:   re   rf   rg   get_list_display__func__r   rh   ri   )rW   r^   r  s   `` r   r   z*ModelAdminChecks._check_list_display_links	  s     	<;;;;;!)IC2T5MBB 	5>RX[`lmmmm!*j.III+ , , , , ,)233I)J)J, , ,      	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.E111rm   )r  r	   r8   r{   r   s       r   r  z/ModelAdminChecks._check_list_display_links_item  sS    S---zzz #    Ir-   c                      t          j        t          t          f          st	          ddd          S t          t          j         fdt          j                  D                                 S )NrZ   list_filterz
admin.E112r\   c              3   R   K   | ]!\  }}                     |d |z            V  "dS )zlist_filter[%d]N)_check_list_filter_itemr  s      r   r4   z6ModelAdminChecks._check_list_filter.<locals>.<genexpr>,  sS       , ,E4 ,,S$8IE8QRR, , , , , ,r-   )r:   r   re   rf   rg   r   rh   ri   rj   s   ``r   r   z#ModelAdminChecks._check_list_filter(  s    #/D%=99 	,]P\]]]]+ , , , , ,#,S_#=#=, , ,     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.E114rm   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	   r8   r{   rf   re   r   rp   r   r
   )rW   r^   r	  r~   r$  r%  ro   list_filter_classs           r   r"  z(ModelAdminChecks._check_list_filter_item1  s    	EDDDDDDDD>> '	*T6<"@"@ '	tZ00 (U-0\C C C C D/22 	LTW\\M'    	udm,, 	'+$E$0/BB (0A'TY/_bgstttt	 E$SY666 	 %&78   LL`e`e`eglglglmM'     s   C* *5D"!D"c                 z    t          |j        t          t          t          f          st          dd|d          S g S )zA 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:   r*  r   re   rf   rg   rj   s     r   r   z+ModelAdminChecks._check_list_select_relatedd  s@     #1D$3FGG 	5>SY\amnnnn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:   r-  intrg   rj   s     r   r   z%ModelAdminChecks._check_list_per_pagel  s5     #+S11 	<S\ZZZZIr-   c                 `    t          |j        t                    st          dd|d          S g S )z- Check that list_max_show_all is an integer. r,  list_max_show_allz
admin.E119r\   )r:   r0  r.  rg   rj   s     r   r   z)ModelAdminChecks._check_list_max_show_allt  s7     #/55 	<0CQ]^^^^Ir-   c                      t          j        t          t          f          st	          ddd          S t          t          j         fdt          j                  D                                 S )zl Check that list_editable is a sequence of editable fields from
        list_display without first element. rZ   list_editablez
admin.E120r\   c              3   R   K   | ]!\  }}                     |d |z            V  "dS )zlist_editable[%d]N)_check_list_editable_itemr  s      r   r4   z8ModelAdminChecks._check_list_editable.<locals>.<genexpr>  sT       , ,E4 ..sD:MPU:UVV, , , , , ,r-   )r:   r2  re   rf   rg   r   rh   ri   rj   s   ``r   r   z%ModelAdminChecks._check_list_editable|  s     #+dE];; 	,_#R^____+ , , , , ,#,S->#?#?, , ,     r-   c                 8   	 |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        s$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.E122rm   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.E121rn   )rp   rq   rr   r  r	   r8   r{   r  editabler
   r}   r   s        r   r4  z*ModelAdminChecks._check_list_editable_item  s   /	IO--j99E !111LL:?%%MM'	    ' !J#:P,P,PLgjttM'    "1%33C<R3*6LL "EE3#3A#6#6#6  M'  	 	 ^ LL!EE:::  M'    	[ ! 	d 	d 	d)
5cVbcccccc	ds   C9 9DDc                 n    t          |j        t          t          f          st	          dd|d          S g S )z$ Check search_fields is a sequence. rZ   r|   z
admin.E126r\   )r:   r|   re   rf   rg   rj   s     r   r   z%ModelAdminChecks._check_search_fields  s;     #+dE];; 	,_#R^____Ir-   c                 D   |j         g S 	 t          |j        |j                   d         }t          |t          j        t          j        f          s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)
zA Check that date_hierarchy refers to DateField or DateTimeField. Nz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.E127rm   )r:  r   rp   r:   r   	DateFieldr   rg   r   r
   r	   r8   r{   )rW   r^   ro   s      r   r   z&ModelAdminChecks._check_date_hierarchy  s     %I,SY8JKKBO "%&*:F<P)QRR "#AJZ`chtuuuuI %&78   L57:7IJM'	     s    A& &6BBc                 2   |                                 }g }|D ]}\  }}}t          |d          s|j        D ]^}d|z  }t          ||          sG|                    t	          j        |j        j        d|d|j        d|j        d                     _~|S )z
        Actions with an allowed_permission attribute require the ModelAdmin to
        implement a has_<perm>_permission() method for each permission.
        allowed_permissionszhas_%s_permissionz must define a z() method for the z action.z
admin.E129rm   )_get_base_actionsr   r=  r7   r	   r8   r{   ry   )	rW   r^   actionsr*   funcr   _
permissionmethod_names	            r   r   z1ModelAdminChecks._check_action_permission_methods  s    
 ''))$ 	 	MD$4!677 "6  
1J>sK00 MM # 6 6 6 + $
 !$+  
 
 
 r-   c           
      *   g }t          j        d |                                D                       }|                                D ]K\  }}|dk    r@|                    t          j        d|j        j        d|d|j        d                     L|S )z.Check that every action has a unique __name__.c              3   "   K   | ]
\  }}}|V  d S r1   r   )r3   rA  r   s      r   r4   z=ModelAdminChecks._check_actions_uniqueness.<locals>.<genexpr>  s(      #S#SZQaD#S#S#S#S#S#Sr-   r   z*__name__ attributes of actions defined in z must be unique. Name z is not unique.z
admin.E130rm   )	collectionsCounterr>  r   r7   r	   r8   r{   ry   )rW   r^   r*   namesr   counts         r   r   z*ModelAdminChecks._check_actions_uniqueness  s    ##S#S3;P;P;R;R#S#S#SSS ;;== 
	 
	KD%qyyfll ...
 #      r-   )ry   r   r   r'   r   r   r   r  r   r  r   r  r   r"  r   r   r   r   r4  r   r   r   r   __classcell__r{   s   @r   r   r     sY       
 
 
 
 
&    	 	 	"= "= "=H
 
 
  B  "    1 1 1f      
 
 
0 0 0d    .  4      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 r1   )	parent_modelr   r'   _check_relation_check_exclude_of_parent_model_check_extra_check_max_num_check_min_num_check_formset)rW   
inline_objr)   rO  r{   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.E201rm   )r   rN   rP  r   r   rp   rY  r   r	   r8   rq   r~   r{   )rW   r^   rO  r*   fkr{   s        r   rQ  z5InlineModelAdminChecks._check_exclude_of_parent_model  s     '',, 	I \22 	I;IlCIs{KKK7ck!! !3!9!9!9 #  	 	 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)NrX  r   z
admin.E202rm   )r   rp   rY  
ValueErrorr	   r8   argsr{   )rW   r^   rO  es       r   rP  z&InlineModelAdminChecks._check_relation0  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. r,  extraz
admin.E203r\   )r:   r`  r.  rg   rj   s     r   rR  z#InlineModelAdminChecks._check_extra8  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. Nr,  max_numz
admin.E204r\   )rb  r:   r.  rg   rj   s     r   rS  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. Nr,  min_numz
admin.E205r\   )re  r:   r.  rg   rj   s     r   rT  z%InlineModelAdminChecks._check_min_numJ  rc  r-   c                 `    t          |j        t                    st          dd|d          S g S )z2 Check formset is a subclass of BaseModelFormSet. r   formsetz
admin.E206r   )r   rg  r   r   rj   s     r   rU  z%InlineModelAdminChecks._check_formsetT  s8     3;(899 	$,>yVY^jkkkkIr-   )ry   r   r   r'   rQ  rP  rR  rS  rT  rU  rJ  rK  s   @r   rM  rM    s        

 

 

 

 

    :              r-   rM  c                 J    t          j        d|d| d|j        |          gS )Nr   z
' must be r  rm   r	   r8   r{   )rz   r]   r^   r/   s       r   rg   rg   ]  s:    /5vvttt<	
 	
 	
 r-   c                 J    t          j        d|d| d|j        |          gS )Nr   z' must inherit from 'r   rm   ri  r   s       r   r   r   g  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   rm   )r	   r8   rp   rq   r~   r{   rn   s       r   r}   r}   q  sK    vvuuucio3335		
 	
 	
 r-   ))rF  	itertoolsr   django.appsr   django.confr   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,   rF   rH   r   rM  rg   r   r}   r   r-   r   <module>ry     sO                                              4 4 4 4 4 4       1 1 1 1 1 1 3 3 3 3 3 3          $ # # # # # ; ; ; ; ; ; 5 5 5 5 5 5    "  U U Upq q q q q q q qh| | | | |+ | | |~U U U U U1 U U Up        r-   