B
    BŒ¶cÓ  ã               @   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   s\  | d krt  tj¡}n8tj d¡\}}x&| D ]}|j|kr,| |¡}P q,W g S g }t|jtt	fƒsx| 
tjd|dd¡ |j|jkrš| 
tjd|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ƒrX| 
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'.z	auth.E002z)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.W004)Úhintr
   r   z%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_BACKENDSÚobject_nameÚWarningZis_anonymousr   ZCriticalÚis_authenticated)Úapp_configsÚkwargsÚclsÚ	app_labelZ
model_nameÚ
app_configÚerrors© r!   úK/var/www/cleansys/lib/python3.7/site-packages/django/contrib/auth/checks.pyÚcheck_user_model   sh    







r#   c          
   K   s€  | d krt  ¡ }nt dd„ | D ƒ¡}t  dd¡}|j d¡j}g }x4|D ]*}|j}tt	|ƒƒ}|r~t
dd„ | ¡ D ƒƒnd}	|	|krÂ||	t|jƒ  }
| tjd|j|j|
|f |d	d
¡ tƒ }x®|jD ]¤\}}t|ƒ|kr| tjd||j|j|f |dd
¡ ||kr<| tjd||j|jf |dd
¡ n.||krj| tjd||j|jf |dd
¡ | |¡ qÐW qLW |S )Nc             s   s   | ]}|  ¡ V  qd S )N)Ú
get_models)Ú.0r   r!   r!   r"   ú	<genexpr>e   s    z+check_models_permissions.<locals>.<genexpr>ÚauthÚ
PermissionÚnamec             s   s   | ]}t |ƒV  qd S )N)Úlen)r%   r)   r!   r!   r"   r&   p   s    r   z}The verbose_name of model '%s.%s' must be at most %d characters for its builtin permission names to be at most %d characters.z	auth.E007)r
   r   zHThe permission named '%s' of model '%s.%s' is longer than %d characters.z	auth.E008zRThe permission codenamed '%s' clashes with a builtin permission for model '%s.%s'.z	auth.E005z>The permission codenamed '%s' is duplicated for model '%s.%s'.z	auth.E006)r   r$   r   Úfrom_iterabler   r   r   Ú
max_lengthÚdictr   ÚmaxÚvaluesr*   Zverbose_name_rawr   r   r   r   r   ÚsetZpermissionsÚadd)r   r   Úmodelsr(   Zpermission_name_max_lengthr    ÚmodelÚoptsZbuiltin_permissionsZ"max_builtin_permission_name_lengthZverbose_name_max_lengthZ	codenamesÚcodenamer)   r!   r!   r"   Úcheck_models_permissionsa   sV    





r6   )N)N)Ú	itertoolsr   Útypesr   Zdjango.appsr   Zdjango.confr   Zdjango.corer   Z
managementr   r#   r6   r!   r!   r!   r"   Ú<module>   s   
V