Ejemplo n.º 1
0
 def __init__(self):
     warnings.warn(
         "`DjangoObjectPermissionsFilter` has been deprecated and moved to "
         "the 3rd-party django-rest-framework-guardian package.",
         RemovedInDRF310Warning, stacklevel=2
     )
     assert is_guardian_installed(), 'Using DjangoObjectPermissionsFilter, but django-guardian is not installed'
Ejemplo n.º 2
0
 def __init__(self):
     warnings.warn(
         "`DjangoObjectPermissionsFilter` has been deprecated and moved to "
         "the 3rd-party django-rest-framework-guardian package.",
         RemovedInDRF310Warning,
         stacklevel=2)
     assert is_guardian_installed(
     ), 'Using DjangoObjectPermissionsFilter, but django-guardian is not installed'
object_permissions_list_view = ObjectPermissionListView.as_view()


class GetQuerysetObjectPermissionInstanceView(generics.RetrieveUpdateDestroyAPIView):
    serializer_class = BasicPermSerializer
    authentication_classes = [authentication.BasicAuthentication]
    permission_classes = [ViewObjectPermissions]

    def get_queryset(self):
        return BasicPermModel.objects.all()


get_queryset_object_permissions_view = GetQuerysetObjectPermissionInstanceView.as_view()


@unittest.skipUnless(is_guardian_installed(), 'django-guardian not installed')
class ObjectPermissionsIntegrationTests(TestCase):
    """
    Integration tests for the object level permissions API.
    """
    def setUp(self):
        from guardian.shortcuts import assign_perm

        # create users
        create = User.objects.create_user
        users = {
            'fullaccess': create('fullaccess', '*****@*****.**', 'password'),
            'readonly': create('readonly', '*****@*****.**', 'password'),
            'writeonly': create('writeonly', '*****@*****.**', 'password'),
            'deleteonly': create('deleteonly', '*****@*****.**', 'password'),
        }
Ejemplo n.º 4
0
class GetQuerysetObjectPermissionInstanceView(
        generics.RetrieveUpdateDestroyAPIView):
    serializer_class = BasicPermSerializer
    authentication_classes = [authentication.BasicAuthentication]
    permission_classes = [ViewObjectPermissions]

    def get_queryset(self):
        return BasicPermModel.objects.all()


get_queryset_object_permissions_view = GetQuerysetObjectPermissionInstanceView.as_view(
)


@unittest.skipUnless(is_guardian_installed(), 'django-guardian not installed')
class ObjectPermissionsIntegrationTests(TestCase):
    """
    Integration tests for the object level permissions API.
    """
    def setUp(self):
        from guardian.shortcuts import assign_perm

        # create users
        create = User.objects.create_user
        users = {
            'fullaccess':
            create('fullaccess', '*****@*****.**', 'password'),
            'readonly':
            create('readonly', '*****@*****.**', 'password'),
            'writeonly':
Ejemplo n.º 5
0
 def __init__(self):
     assert is_guardian_installed(
     ), 'Using DjangoObjectPermissionsFilter, but django-guardian is not installed'
Ejemplo n.º 6
0
 def __init__(self):
     assert is_guardian_installed(), 'Using DjangoObjectPermissionsFilter, but django-guardian is not installed'