
 X(                 @   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
 d  Z d	 d d  Z d	 S)    )unicode_literals)chain)apps)settings)checks)six   )_get_builtin_permissionsNc          	   K   s  |  d  k r! t  j t j  } nO t j j d  \ } } x4 |  D]( } | j | k r@ | j |  } Pq@ q@ Wg  Sg  } t | j t t	 f  s | j
 t j d d | d d  n  | j | j k r | j
 t j d d | d d  n  | j j | j  j st j d g k rL| j
 t j d	 | j j | j f d | d d
  q| j
 t j d | j j | j f d d d | d d  n  t |   j t j j  r| j
 t j d | d | d d  n  t |   j t j j  r| j
 t j d | d | d d  n  | S)N.z*'REQUIRED_FIELDS' must be a list or tuple.objidz	auth.E001zjThe 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.ZhintzKEnsure 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_BACKENDSobject_nameWarningZis_anonymousr   types
MethodTypeZCriticalZis_authenticated)app_configskwargscls	app_labelZ
model_name
app_configerrors r"   H/home/ubuntu/projects/ifolica/build/django/django/contrib/auth/checks.pycheck_user_model   sh    r$   c          	   K   s"  |  d  k r t  j   } n t j d d   |  D  } t  j d d  } | j j d  j } g  } x| D]} | j } t t	 |   } | r t
 d d   | j   D  n d }	 |	 | k r| |	 t | j  }
 | j t j d | j | j |
 | f d	 | d
 d  n  t   } x | j D] \ } } t |  | k r| j t j d | | j | j | f d	 | d
 d  n  | | k r| j t j d | | j | j f d	 | d
 d  nD | | k r	| j t j d | | j | j f d	 | d
 d  n  | j |  q(Wqk W| S)Nc             s   s   |  ] } | j    Vq d  S)N)
get_models).0r    r"   r"   r#   	<genexpr>h   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'   s   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.r   r   z	auth.E007zHThe 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	codenamesZcodenamer*   r"   r"   r#   check_models_permissionsd   sV    	+	r6   )
__future__r   	itertoolsr   Zdjango.appsr   Zdjango.confr   Zdjango.corer   Zdjango.utilsr   Z
managementr	   r$   r6   r"   r"   r"   r#   <module>   s   V