U
    8ÄT_Ë  ã                   @   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	d
„Zddd„ZdS )é    )Úchain)Ú
MethodType)Úapps)Úsettings)Úchecksé   )Ú_get_builtin_permissionsNc                 K   sh  | d krt  tj¡}n6tj d¡\}}| D ]}|j|kr*| |¡} qLq*g S g }t|jtt	fƒsv| 
tjd|dd�¡ |j|jkr¦| 
tjdd|j|jf |dd�¡ |j |j¡j�st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ƒ�rd| 
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   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   ZAUTH_USER_MODELÚsplitÚlabelÚ
isinstanceZREQUIRED_FIELDSÚlistÚtupleÚappendr   ÚErrorZUSERNAME_FIELDÚ_metaÚ	get_fieldÚuniqueZAUTHENTICATION_BACKENDSZobject_nameÚWarningZis_anonymousr   ZCriticalÚis_authenticated)Úapp_configsÚkwargsÚclsZ	app_labelÚ
model_nameÚ
app_configÚerrors© r!   ú>/tmp/pip-unpacked-wheel-dv63caxw/django/contrib/auth/checks.pyÚcheck_user_model   s”    

ýÿ	
þ÷ÿÿ ÿûÿ
 ÿúÿþûÿ	þûÿ	r#   c              	   K   s  | d krt  ¡ }nt dd„ | D ƒ¡}t  dd¡}|j d¡j}|j d¡j}g }|D �]¤}|j}tt	|ƒƒ}	|	rˆt
dd„ |	 ¡ D ƒƒnd}
|
|krÈ||
t|jƒ  }| tjd	|j||f |d
d�¡ |	rât
dd„ |	 ¡ D ƒƒnd}||k�r$||t|jƒ  }| tjd|j||f |dd�¡ tƒ }|jD ]Ê\}}t|ƒ|k�rh| tjd||j|f |dd�¡ t|ƒ|k�r˜| tjd||j|f |dd�¡ ||	k�rÄ| tjd||jf |dd�¡ n*||k�rî| tjd||jf |dd�¡ | |¡ �q0qV|S )Nc                 s   s   | ]}|  ¡ V  qd S ©N)Ú
get_models)Ú.0r   r!   r!   r"   Ú	<genexpr>j   s     z+check_models_permissions.<locals>.<genexpr>ÚauthÚ
PermissionÚnameÚcodenamec                 s   s   | ]}t |ƒV  qd S r$   ©Úlen)r&   r*   r!   r!   r"   r'   v   s     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   s   | ]}t |ƒV  qd S r$   r,   )r&   r+   r!   r!   r"   r'   Š   s     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Úvaluesr-   Zverbose_name_rawr   r   r   r   Úkeysr   ÚsetÚpermissionsÚadd)r   r   Úmodelsr)   Zpermission_name_max_lengthZpermission_codename_max_lengthr    ÚmodelÚoptsZbuiltin_permissionsZ"max_builtin_permission_name_lengthZverbose_name_max_lengthZ&max_builtin_permission_codename_lengthZmodel_name_max_lengthZ	codenamesr+   r*   r!   r!   r"   Úcheck_models_permissionsf   sÆ    

ÿþÿ  ÿþùÿÿþ
ÿýþ÷ÿ  ÿÿúÿýÿøÿ
ÿüÿ
ÿüÿr:   )N)N)Ú	itertoolsr   Útypesr   Zdjango.appsr   Zdjango.confr   Zdjango.corer   Z
managementr   r#   r:   r!   r!   r!   r"   Ú<module>   s   
[