o
    {,hw&                     @   s|   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 ddlmZ d	d
 ZdddZdddZdd ZdS )    )chain)
MethodType)apps)settings)checks)import_string   )_get_builtin_permissionsc              
   C   sT   t | }t|D ]\}}zt |}t||r|W   S W q ttfy'   Y qw dS )z
    Return the index of dotted class path (or a subclass of that class) in a
    list of candidate paths. If it does not exist, return -1.
    )r   	enumerate
issubclassImportError	TypeError)
class_pathcandidate_pathsclsindexpathcandidate_cls r   P/var/www/html/rh/venv/lib/python3.10/site-packages/django/contrib/auth/checks.py_subclass_index   s   

r   Nc                    s|  | d u rt tj ntjd\}}| D ]}|j|kr#||  nqg S g }t jtt	fs;|
tjd dd  j jv rS|
tjdd j jf  dd  j jjst fd	d
 jjD stjdgkr|
tjd jj jf  dd n|
tjd jj jf d dd t  jtr|
tjd   dd t  jtr|
tjd   dd |S )N.z*'REQUIRED_FIELDS' must be a list or tuple.z	auth.E001objidzjThe field named as the 'USERNAME_FIELD' for a custom user model must not be included in 'REQUIRED_FIELDS'.zaThe 'USERNAME_FIELD' is currently set to '%s', you should remove '%s' from the 'REQUIRED_FIELDS'.z	auth.E002)hintr   r   c                 3   s    | ]
}|j  jfkV  qd S N)fieldsUSERNAME_FIELD).0
constraintr   r   r   	<genexpr>H   s
    
z#check_user_model.<locals>.<genexpr>z)django.contrib.auth.backends.ModelBackendzC'%s.%s' must be unique because it is named as the 'USERNAME_FIELD'.z	auth.E003z?'%s.%s' is named as the 'USERNAME_FIELD', but it is not unique.zKEnsure that your authentication backend(s) can handle non-unique usernames.z	auth.W004z%s.is_anonymous must be an attribute or property rather than a method. Ignoring this is a security issue as anonymous users will be treated as authenticated!z	auth.C009z%s.is_authenticated must be an attribute or property rather than a method. Ignoring this is a security issue as anonymous users will be treated as authenticated!z	auth.C010)r   	get_modelr   AUTH_USER_MODELsplitlabel
isinstanceREQUIRED_FIELDSlisttupleappendr   Errorr   _meta	get_fielduniqueanytotal_unique_constraintsAUTHENTICATION_BACKENDSobject_nameWarningis_anonymousr   Criticalis_authenticated)app_configskwargs	app_label
model_name
app_configerrorsr   r"   r   check_user_model   s   

	
			r?   c              	   K   s  | d u r	t  }n
tdd | D }t dd}|jdj}|jdj}g }|D ]}|j}tt	|}	|	rCt
dd |	 D nd}
|
|krc||
t|j  }|tjd	|j||f |d
d |	rpt
dd |	 D nd}||kr||t|j  }|tjd|j||f |dd t }|jD ]`\}}t||kr|tjd||j|f |dd t||kr|tjd||j|f |dd ||	v r|tjd||jf |dd n||v r|tjd||jf |dd || qq+|S )Nc                 s   s    | ]}|  V  qd S r   )
get_models)r    r=   r   r   r   r#      s    
z+check_models_permissions.<locals>.<genexpr>auth
Permissionnamecodenamec                 s       | ]}t |V  qd S r   len)r    rC   r   r   r   r#          r   zzThe verbose_name of model '%s' must be at most %d characters for its builtin permission names to be at most %d characters.z	auth.E007r   c                 s   rE   r   rF   )r    rD   r   r   r   r#      rH   zvThe name of model '%s' must be at most %d characters for its builtin permission codenames to be at most %d characters.z	auth.E011zEThe permission named '%s' of model '%s' is longer than %d characters.z	auth.E008zIThe permission codenamed '%s' of model '%s' is longer than %d characters.z	auth.E012zOThe permission codenamed '%s' clashes with a builtin permission for model '%s'.z	auth.E005z;The permission codenamed '%s' is duplicated for model '%s'.z	auth.E006)r   r@   r   from_iterabler$   r.   r/   
max_lengthdictr	   maxvaluesrG   verbose_name_rawr,   r   r-   r'   keysr<   setpermissionsadd)r9   r:   modelsrB   permission_name_max_lengthpermission_codename_max_lengthr>   modeloptsbuiltin_permissions"max_builtin_permission_name_lengthverbose_name_max_length&max_builtin_permission_codename_lengthmodel_name_max_length	codenamesrD   rC   r   r   r   check_models_permissions|   s   


4r^   c                 K   sL   g }t dtj}|dkr$t dtj}|dks||kr$|tjddd |S )Nz6django.contrib.auth.middleware.LoginRequiredMiddlewarer
   z7django.contrib.auth.middleware.AuthenticationMiddlewarezIn order to use django.contrib.auth.middleware.LoginRequiredMiddleware, django.contrib.auth.middleware.AuthenticationMiddleware must be defined before it in MIDDLEWARE.z	auth.E013)r   )r   r   
MIDDLEWAREr,   r   r-   )r9   r:   r>   login_required_index
auth_indexr   r   r   check_middleware   s$   rb   r   )	itertoolsr   typesr   django.appsr   django.confr   django.corer   django.utils.module_loadingr   
managementr	   r   r?   r^   rb   r   r   r   r   <module>   s    

`t