Why Gemfury? Push, build, and install  RubyGems npm packages Python packages Maven artifacts PHP packages Go Modules Debian packages RPM packages NuGet packages

Repository URL to install this package:

Details    
djangorestframework / __pycache__ / permissions.cpython-35.pyc
Size: Mime:


ÕÉXÿã@sdZddlmZddlmZddlmZddlmZdZ	Gd	d
„d
e
ƒZGdd„deƒZGd
d„deƒZ
Gdd„deƒZGdd„deƒZGdd„deƒZGdd„deƒZGdd„deƒZdS)z2
Provides a set of pluggable permission policies.
é)Úunicode_literals)ÚHttp404)Ú
exceptions)Úis_authenticatedÚGETÚHEADÚOPTIONSc@s.eZdZdZdd„Zdd„ZdS)ÚBasePermissionzH
    A base class from which all permission classes should inherit.
    cCsdS)zL
        Return `True` if permission is granted, `False` otherwise.
        T©)ÚselfÚrequestÚviewr
r
úY/Users/carlton/Documents/Django-Stack/django-rest-framework/rest_framework/permissions.pyÚhas_permissionszBasePermission.has_permissioncCsdS)zL
        Return `True` if permission is granted, `False` otherwise.
        Tr
)rrr
Úobjr
r
rÚhas_object_permissionsz$BasePermission.has_object_permissionN)Ú__name__Ú
__module__Ú__qualname__Ú__doc__rrr
r
r
rr	sr	c@s"eZdZdZdd„ZdS)ÚAllowAnyz¹
    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.
    cCsdS)NTr
)rrr
r
r
rr(szAllowAny.has_permissionN)rrrrrr
r
r
rr src@s"eZdZdZdd„ZdS)ÚIsAuthenticatedz4
    Allows access only to authenticated users.
    cCs|jot|jƒS)N)Úuserr)rrr
r
r
rr1szIsAuthenticated.has_permissionN)rrrrrr
r
r
rr,src@s"eZdZdZdd„ZdS)ÚIsAdminUserz,
    Allows access only to admin users.
    cCs|jo|jjS)N)rÚis_staff)rrr
r
r
rr:szIsAdminUser.has_permissionN)rrrrrr
r
r
rr5src@s"eZdZdZdd„ZdS)ÚIsAuthenticatedOrReadOnlyzL
    The request is authenticated as a user, or is a read-only request.
    cCs%|jtkp$|jo$t|jƒS)N)ÚmethodÚSAFE_METHODSrr)rrr
r
r
rrCs	z(IsAuthenticatedOrReadOnly.has_permissionN)rrrrrr
r
r
rr>src@speZdZdZdgdgdgddgddgd	dgd
dgiZdZd
d„Zdd„ZdS)ÚDjangoModelPermissionsa}
    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.
    rrrÚPOSTz %(app_label)s.add_%(model_name)sÚPUTz#%(app_label)s.change_%(model_name)sÚPATCHÚDELETEz#%(app_label)s.delete_%(model_name)sTcsZd|jjd|jji‰||jkr<tj|ƒ‚‡fdd†|j|DƒS)z‚
        Given a model and an HTTP method, return the list of permission
        codes that the user is required to have.
        Ú	app_labelÚ
model_namecsg|]}|ˆ‘qSr
r
)Ú.0Úperm)Úkwargsr
rú
<listcomp>ss	zCDjangoModelPermissions.get_required_permissions.<locals>.<listcomp>)Ú_metar#r$Ú	perms_maprÚMethodNotAllowed)rrÚ	model_clsr
)r'rÚget_required_permissionsfs
z/DjangoModelPermissions.get_required_permissionscCs¨t|ddƒrdSt|dƒr4|jƒ}nt|ddƒ}|dk	s^tdƒ‚|j|j|jƒ}|jo§t|jƒs˜|j	o§|jj
|ƒS)NZ_ignore_model_permissionsFTÚget_querysetÚquerysetzoCannot apply DjangoModelPermissions on a view that does not set `.queryset` or have a `.get_queryset()` method.)ÚgetattrÚhasattrr.ÚAssertionErrorr-rÚmodelrrÚauthenticated_users_onlyÚ	has_perms)rrr
r/Úpermsr
r
rrus		z%DjangoModelPermissions.has_permissionN)rrrrr*r4r-rr
r
r
rrKs
			rc@seZdZdZdZdS)Ú$DjangoModelPermissionsOrAnonReadOnlyzj
    Similar to DjangoModelPermissions, except that anonymous users are
    allowed read-only access.
    FN)rrrrr4r
r
r
rr7Žsr7c@sjeZdZdZdgdgdgddgddgd	dgd
dgiZdd
„Zdd„ZdS)ÚDjangoObjectPermissionsa—
    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.
    rrrrz %(app_label)s.add_%(model_name)sr z#%(app_label)s.change_%(model_name)sr!r"z#%(app_label)s.delete_%(model_name)scsZd|jjd|jji‰||jkr<tj|ƒ‚‡fdd†|j|DƒS)Nr#r$csg|]}|ˆ‘qSr
r
)r%r&)r'r
rr(´s	zKDjangoObjectPermissions.get_required_object_permissions.<locals>.<listcomp>)r)r#r$r*rr+)rrr,r
)r'rÚget_required_object_permissions«s
z7DjangoObjectPermissions.get_required_object_permissionsc	CsÈt|dƒr|jƒ}nt|ddƒ}|dk	sHtdƒ‚|j}|j}|j|j|ƒ}|j||ƒsÄ|jt	kr–t
‚|jd|ƒ}|j||ƒsÀt
‚dSdS)Nr.r/zpCannot apply DjangoObjectPermissions on a view that does not set `.queryset` or have a `.get_queryset()` method.rFT)r1r.r0r2r3rr9rr5rr)	rrr
rr/r,rr6Z
read_permsr
r
rr¶s 			z-DjangoObjectPermissions.has_object_permissionN)rrrrr*r9rr
r
r
rr8–s
			r8N)zGETzHEADzOPTIONS)rÚ
__future__rÚdjango.httprÚrest_frameworkrÚrest_framework.compatrrÚobjectr	rrrrrr7r8r
r
r
rÚ<module>s		
C