ó
pÁìVc           @  sà   d  Z  d d l m Z d d l m Z d Z d e f d „  ƒ  YZ d	 e f d
 „  ƒ  YZ d e f d „  ƒ  YZ	 d e f d „  ƒ  YZ
 d e f d „  ƒ  YZ d e f d „  ƒ  YZ d e f d „  ƒ  YZ d e f d „  ƒ  YZ d S(   u2   
Provides a set of pluggable permission policies.
iÿÿÿÿ(   t   unicode_literals(   t   Http404u   GETu   HEADu   OPTIONSt   BasePermissionc           B  s    e  Z d  Z d „  Z d „  Z RS(   uH   
    A base class from which all permission classes should inherit.
    c         C  s   t  S(   uL   
        Return `True` if permission is granted, `False` otherwise.
        (   t   True(   t   selft   requestt   view(    (    st   /opt/seafile/seafile-server-5.1.3/seahub/thirdpart/djangorestframework-3.3.2-py2.7.egg/rest_framework/permissions.pyt   has_permission   s    c         C  s   t  S(   uL   
        Return `True` if permission is granted, `False` otherwise.
        (   R   (   R   R   R   t   obj(    (    st   /opt/seafile/seafile-server-5.1.3/seahub/thirdpart/djangorestframework-3.3.2-py2.7.egg/rest_framework/permissions.pyt   has_object_permission   s    (   t   __name__t
   __module__t   __doc__R   R	   (    (    (    st   /opt/seafile/seafile-server-5.1.3/seahub/thirdpart/djangorestframework-3.3.2-py2.7.egg/rest_framework/permissions.pyR      s   	t   AllowAnyc           B  s   e  Z d  Z d „  Z RS(   u¹   
    Allow any access.
    This isn't strictly required, since you could use an empty
    permission_classes list, but it's useful because it makes the intention
    more explicit.
    c         C  s   t  S(   N(   R   (   R   R   R   (    (    st   /opt/seafile/seafile-server-5.1.3/seahub/thirdpart/djangorestframework-3.3.2-py2.7.egg/rest_framework/permissions.pyR   $   s    (   R
   R   R   R   (    (    (    st   /opt/seafile/seafile-server-5.1.3/seahub/thirdpart/djangorestframework-3.3.2-py2.7.egg/rest_framework/permissions.pyR      s   t   IsAuthenticatedc           B  s   e  Z d  Z d „  Z RS(   u4   
    Allows access only to authenticated users.
    c         C  s   | j  o | j  j ƒ  S(   N(   t   usert   is_authenticated(   R   R   R   (    (    st   /opt/seafile/seafile-server-5.1.3/seahub/thirdpart/djangorestframework-3.3.2-py2.7.egg/rest_framework/permissions.pyR   -   s    (   R
   R   R   R   (    (    (    st   /opt/seafile/seafile-server-5.1.3/seahub/thirdpart/djangorestframework-3.3.2-py2.7.egg/rest_framework/permissions.pyR   (   s   t   IsAdminUserc           B  s   e  Z d  Z d „  Z RS(   u,   
    Allows access only to admin users.
    c         C  s   | j  o | j  j S(   N(   R   t   is_staff(   R   R   R   (    (    st   /opt/seafile/seafile-server-5.1.3/seahub/thirdpart/djangorestframework-3.3.2-py2.7.egg/rest_framework/permissions.pyR   6   s    (   R
   R   R   R   (    (    (    st   /opt/seafile/seafile-server-5.1.3/seahub/thirdpart/djangorestframework-3.3.2-py2.7.egg/rest_framework/permissions.pyR   1   s   t   IsAuthenticatedOrReadOnlyc           B  s   e  Z d  Z d „  Z RS(   uL   
    The request is authenticated as a user, or is a read-only request.
    c         C  s%   | j  t k p$ | j o$ | j j ƒ  S(   N(   t   methodt   SAFE_METHODSR   R   (   R   R   R   (    (    st   /opt/seafile/seafile-server-5.1.3/seahub/thirdpart/djangorestframework-3.3.2-py2.7.egg/rest_framework/permissions.pyR   ?   s    	(   R
   R   R   R   (    (    (    st   /opt/seafile/seafile-server-5.1.3/seahub/thirdpart/djangorestframework-3.3.2-py2.7.egg/rest_framework/permissions.pyR   :   s   t   DjangoModelPermissionsc           B  si   e  Z d  Z i g  d 6g  d 6g  d 6d g d 6d g d 6d g d 6d	 g d
 6Z e Z d „  Z d „  Z RS(   u}  
    The request is authenticated using `django.contrib.auth` permissions.
    See: https://docs.djangoproject.com/en/dev/topics/auth/#permissions

    It ensures that the user is authenticated, and has the appropriate
    `add`/`change`/`delete` permissions on the model.

    This permission can only be applied against view classes that
    provide a `.queryset` attribute.
    u   GETu   OPTIONSu   HEADu    %(app_label)s.add_%(model_name)su   POSTu#   %(app_label)s.change_%(model_name)su   PUTu   PATCHu#   %(app_label)s.delete_%(model_name)su   DELETEc         C  sB   i | j  j d 6| j  j d 6} g  |  j | D] } | | ^ q. S(   u‚   
        Given a model and an HTTP method, return the list of permission
        codes that the user is required to have.
        u	   app_labelu
   model_name(   t   _metat	   app_labelt
   model_namet	   perms_map(   R   R   t	   model_clst   kwargst   perm(    (    st   /opt/seafile/seafile-server-5.1.3/seahub/thirdpart/djangorestframework-3.3.2-py2.7.egg/rest_framework/permissions.pyt   get_required_permissionsb   s    c         C  s¨   t  | d t ƒ r t St | d ƒ r4 | j ƒ  } n t  | d d  ƒ } | d  k	 s^ t d ƒ ‚ |  j | j | j	 ƒ } | j
 o§ | j
 j ƒ  s˜ |  j o§ | j
 j | ƒ S(   Nu   _ignore_model_permissionsu   get_querysetu   querysetuo   Cannot apply DjangoModelPermissions on a view that does not set `.queryset` or have a `.get_queryset()` method.(   t   getattrt   FalseR   t   hasattrt   get_querysett   Nonet   AssertionErrorR   R   t   modelR   R   t   authenticated_users_onlyt	   has_perms(   R   R   R   t   querysett   perms(    (    st   /opt/seafile/seafile-server-5.1.3/seahub/thirdpart/djangorestframework-3.3.2-py2.7.egg/rest_framework/permissions.pyR   m   s    		(   R
   R   R   R   R   R&   R   R   (    (    (    st   /opt/seafile/seafile-server-5.1.3/seahub/thirdpart/djangorestframework-3.3.2-py2.7.egg/rest_framework/permissions.pyR   G   s   



	t$   DjangoModelPermissionsOrAnonReadOnlyc           B  s   e  Z d  Z e Z RS(   uj   
    Similar to DjangoModelPermissions, except that anonymous users are
    allowed read-only access.
    (   R
   R   R   R    R&   (    (    (    st   /opt/seafile/seafile-server-5.1.3/seahub/thirdpart/djangorestframework-3.3.2-py2.7.egg/rest_framework/permissions.pyR*   †   s   t   DjangoObjectPermissionsc           B  sc   e  Z d  Z i g  d 6g  d 6g  d 6d g d 6d g d 6d g d 6d	 g d
 6Z d „  Z d „  Z RS(   u—  
    The request is authenticated using Django's object-level permissions.
    It requires an object-permissions-enabled backend, such as Django Guardian.

    It ensures that the user is authenticated, and has the appropriate
    `add`/`change`/`delete` permissions on the object using .has_perms.

    This permission can only be applied against view classes that
    provide a `.queryset` attribute.
    u   GETu   OPTIONSu   HEADu    %(app_label)s.add_%(model_name)su   POSTu#   %(app_label)s.change_%(model_name)su   PUTu   PATCHu#   %(app_label)s.delete_%(model_name)su   DELETEc         C  sB   i | j  j d 6| j  j d 6} g  |  j | D] } | | ^ q. S(   Nu	   app_labelu
   model_name(   R   R   R   R   (   R   R   R   R   R   (    (    st   /opt/seafile/seafile-server-5.1.3/seahub/thirdpart/djangorestframework-3.3.2-py2.7.egg/rest_framework/permissions.pyt   get_required_object_permissions¤   s    c   	      C  sÎ   t  | d ƒ r | j ƒ  } n t | d d  ƒ } | d  k	 sH t d ƒ ‚ | j } | j } |  j | j | ƒ } | j	 | | ƒ sÊ | j t
 k r™ t ‚ n  |  j d | ƒ } | j	 | | ƒ sÆ t ‚ n  t St S(   Nu   get_querysetu   querysetup   Cannot apply DjangoObjectPermissions on a view that does not set `.queryset` or have a `.get_queryset()` method.u   GET(   R!   R"   R   R#   R$   R%   R   R,   R   R'   R   R   R    R   (	   R   R   R   R   R(   R   R   R)   t
   read_perms(    (    st   /opt/seafile/seafile-server-5.1.3/seahub/thirdpart/djangorestframework-3.3.2-py2.7.egg/rest_framework/permissions.pyR	   «   s     					(   R
   R   R   R   R,   R	   (    (    (    st   /opt/seafile/seafile-server-5.1.3/seahub/thirdpart/djangorestframework-3.3.2-py2.7.egg/rest_framework/permissions.pyR+   Ž   s   



	N(   u   GETu   HEADu   OPTIONS(   R   t
   __future__R    t   django.httpR   R   t   objectR   R   R   R   R   R   R*   R+   (    (    (    st   /opt/seafile/seafile-server-5.1.3/seahub/thirdpart/djangorestframework-3.3.2-py2.7.egg/rest_framework/permissions.pyt   <module>   s   		?