ó
®â0_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 l m Z d d	 „ Z d d
 „ Z d S(   iÿÿÿÿ(   t   unicode_literals(   t   chain(   t
   MethodType(   t   apps(   t   settings(   t   checksi   (   t   _get_builtin_permissionsc      	   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 ƒ rÈ| j t j d | d | d d ƒƒ n  t | ƒ  j t ƒ r| j t j d | d | d d ƒƒ n  | S(   Nu   .u*   'REQUIRED_FIELDS' must be a list or tuple.t   objt   idu	   auth.E001uj   The field named as the 'USERNAME_FIELD' for a custom user model must not be included in 'REQUIRED_FIELDS'.u	   auth.E002u)   django.contrib.auth.backends.ModelBackenduC   '%s.%s' must be unique because it is named as the 'USERNAME_FIELD'.u	   auth.E003u?   '%s.%s' is named as the 'USERNAME_FIELD', but it is not unique.t   hintuK   Ensure that your authentication backend(s) can handle non-unique usernames.u	   auth.W004u   %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!u	   auth.C009u¡   %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!u	   auth.C010(   t   NoneR   t	   get_modelR   t   AUTH_USER_MODELt   splitt   labelt
   isinstancet   REQUIRED_FIELDSt   listt   tuplet   appendR   t   Errort   USERNAME_FIELDt   _metat	   get_fieldt   uniquet   AUTHENTICATION_BACKENDSt   object_namet   Warningt   is_anonymousR   t   Criticalt   is_authenticated(   t   app_configst   kwargst   clst	   app_labelt
   model_namet
   app_configt   errors(    (    s<   /tmp/pip-unpacked-wheel-BAJOf3/django/contrib/auth/checks.pyt   check_user_model   sh    c      	   K  s  |  d  k r t j ƒ  } n t j d „  |  Dƒ ƒ } t j d d ƒ } | j j d ƒ j } g  } x´| D]¬} | j } t	 t
 | ƒ ƒ } | r« t 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"Wqh W| S(   Nc         s  s   |  ] } | j  ƒ  Vq d  S(   N(   t
   get_models(   t   .0R$   (    (    s<   /tmp/pip-unpacked-wheel-BAJOf3/django/contrib/auth/checks.pys	   <genexpr>h   s    u   authu
   Permissionu   namec         s  s   |  ] } t  | ƒ Vq d  S(   N(   t   len(   R(   t   name(    (    s<   /tmp/pip-unpacked-wheel-BAJOf3/django/contrib/auth/checks.pys	   <genexpr>s   s    i    u}   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   u	   auth.E007uH   The permission named '%s' of model '%s.%s' is longer than %d characters.u	   auth.E008uR   The permission codenamed '%s' clashes with a builtin permission for model '%s.%s'.u	   auth.E005u>   The permission codenamed '%s' is duplicated for model '%s.%s'.u	   auth.E006(   R
   R   R'   R   t   from_iterableR   R   R   t
   max_lengtht   dictR   t   maxt   valuesR)   t   verbose_name_rawR   R   R   R"   R   t   sett   permissionst   add(   R   R    t   modelst
   Permissiont   permission_name_max_lengthR%   t   modelt   optst   builtin_permissionst"   max_builtin_permission_name_lengtht   verbose_name_max_lengtht	   codenamest   codenameR*   (    (    s<   /tmp/pip-unpacked-wheel-BAJOf3/django/contrib/auth/checks.pyt   check_models_permissionsd   sV    	(	N(   t
   __future__R    t	   itertoolsR   t   typesR   t   django.appsR   t   django.confR   t   django.coreR   t
   managementR   R
   R&   R>   (    (    (    s<   /tmp/pip-unpacked-wheel-BAJOf3/django/contrib/auth/checks.pyt   <module>   s   V