3
gN                  @   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                s  | d krt jtj n8tjjd\}}x&| D ]}|j|kr,|j| P q,W g S g }t jtt	fsx|j
tjd dd  j jkr|j
tjdd j jf  dd  jj jj ot fd	d
 jjD  r2tjdgkr|j
tjd jj jf  dd n&|j
tjd jj jf d dd t  jtr\|j
tjd   dd t  jtr|j
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)cls X/var/www/tester-filtro-web/env/lib/python3.6/site-packages/django/contrib/auth/checks.py	<genexpr>8   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   ZAUTH_USER_MODELsplitlabel
isinstanceZREQUIRED_FIELDSlisttupleappendr   Errorr   _meta	get_fielduniqueanyZtotal_unique_constraintsZAUTHENTICATION_BACKENDSZobject_nameWarningZis_anonymousr   ZCriticalis_authenticated)app_configskwargsZ	app_label
model_name
app_configerrorsr   )r   r   check_user_model   sp    









r(   c             K   s  | d krt j }ntjdd | D }t jdd}|jjdj}|jjdj}g }x|D ]}|j}tt	|}	|	rt
dd |	j D nd}
|
|kr||
t|j  }|jtjd	|j||f |d
d |	rt
dd |	j D nd}||kr(||t|j  }|jtjd|j||f |dd t }x|jD ]\}}t||krn|jtjd||j|f |dd t||kr|jtjd||j|f |dd ||	kr|jtjd||jf |dd n*||kr|jtjd||jf |dd |j| q6W qZW |S )Nc             s   s   | ]}|j  V  qd S )N)
get_models)r   r&   r   r   r   r   m   s    z+check_models_permissions.<locals>.<genexpr>auth
Permissionnamecodenamec             s   s   | ]}t |V  qd S )N)len)r   r,   r   r   r   r   y   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.E007)r
   r   c             s   s   | ]}t |V  qd S )N)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%   setZ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_permissionsi   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   
^