From 11eb2bcbd3ffc868027fe9a5fee8429a336a4ab8 Mon Sep 17 00:00:00 2001 From: Ian Ross Date: Wed, 30 Mar 2016 21:35:46 +0200 Subject: [PATCH] Upgrade to django-tutelary 0.1.10 Split PermissionRequiredMixin into "normal" and API cases. --- cadasta/organization/views/api.py | 23 ++++++++++++----------- requirements/common.txt | 2 +- 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/cadasta/organization/views/api.py b/cadasta/organization/views/api.py index 080f1d337..8027bd9ed 100644 --- a/cadasta/organization/views/api.py +++ b/cadasta/organization/views/api.py @@ -2,7 +2,7 @@ from rest_framework import generics from rest_framework import filters, status -from tutelary.mixins import PermissionRequiredMixin +from tutelary.mixins import APIPermissionRequiredMixin from accounts.models import User @@ -11,7 +11,7 @@ from ..mixins import OrganizationRoles, ProjectRoles -class OrganizationList(PermissionRequiredMixin, generics.ListCreateAPIView): +class OrganizationList(APIPermissionRequiredMixin, generics.ListCreateAPIView): queryset = Organization.objects.all() serializer_class = serializers.OrganizationSerializer filter_backends = (filters.DjangoFilterBackend, @@ -27,7 +27,7 @@ class OrganizationList(PermissionRequiredMixin, generics.ListCreateAPIView): permission_filter_queryset = ('org.view',) -class OrganizationDetail(PermissionRequiredMixin, +class OrganizationDetail(APIPermissionRequiredMixin, generics.RetrieveUpdateAPIView): def patch_actions(self, request): if hasattr(request, 'data'): @@ -48,7 +48,7 @@ def patch_actions(self, request): } -class OrganizationUsers(PermissionRequiredMixin, +class OrganizationUsers(APIPermissionRequiredMixin, OrganizationRoles, generics.ListCreateAPIView): serializer_class = serializers.OrganizationUserSerializer @@ -58,7 +58,7 @@ class OrganizationUsers(PermissionRequiredMixin, } -class OrganizationUsersDetail(PermissionRequiredMixin, +class OrganizationUsersDetail(APIPermissionRequiredMixin, OrganizationRoles, generics.RetrieveUpdateDestroyAPIView): serializer_class = serializers.OrganizationUserSerializer @@ -72,7 +72,7 @@ def destroy(self, request, *args, **kwargs): return Response(status=status.HTTP_204_NO_CONTENT) -class UserAdminList(PermissionRequiredMixin, generics.ListAPIView): +class UserAdminList(APIPermissionRequiredMixin, generics.ListAPIView): queryset = User.objects.all() serializer_class = serializers.UserAdminSerializer filter_backends = (filters.DjangoFilterBackend, @@ -84,7 +84,8 @@ class UserAdminList(PermissionRequiredMixin, generics.ListAPIView): permission_required = 'user.list' -class UserAdminDetail(PermissionRequiredMixin, generics.RetrieveUpdateAPIView): +class UserAdminDetail(APIPermissionRequiredMixin, + generics.RetrieveUpdateAPIView): serializer_class = serializers.UserAdminSerializer queryset = User.objects.all() lookup_field = 'username' @@ -94,7 +95,7 @@ class UserAdminDetail(PermissionRequiredMixin, generics.RetrieveUpdateAPIView): } -class ProjectList(PermissionRequiredMixin, generics.ListCreateAPIView): +class ProjectList(APIPermissionRequiredMixin, generics.ListCreateAPIView): serializer_class = serializers.ProjectSerializer filter_backends = (filters.DjangoFilterBackend, filters.SearchFilter, @@ -129,7 +130,7 @@ def get_queryset(self): return self.get_organization().projects.all() -class ProjectDetail(PermissionRequiredMixin, +class ProjectDetail(APIPermissionRequiredMixin, generics.RetrieveUpdateDestroyAPIView): def patch_actions(self, request): if hasattr(request, 'data'): @@ -170,7 +171,7 @@ def get_queryset(self): return self.get_organization().projects.all() -class ProjectUsers(PermissionRequiredMixin, +class ProjectUsers(APIPermissionRequiredMixin, ProjectRoles, generics.ListCreateAPIView): serializer_class = serializers.ProjectUserSerializer @@ -180,7 +181,7 @@ class ProjectUsers(PermissionRequiredMixin, } -class ProjectUsersDetail(PermissionRequiredMixin, +class ProjectUsersDetail(APIPermissionRequiredMixin, ProjectRoles, generics.RetrieveUpdateDestroyAPIView): serializer_class = serializers.ProjectUserSerializer diff --git a/requirements/common.txt b/requirements/common.txt index ad0cc0554..7d7a91071 100644 --- a/requirements/common.txt +++ b/requirements/common.txt @@ -12,7 +12,7 @@ django-leaflet==0.18.0 jsonschema==2.5.1 rfc3987==1.3.5 drfdocs==0.0.9 -django-tutelary==0.1.9 +django-tutelary==0.1.10 django-audit-log==0.7.0 simplejson==3.8.1 django-widget-tweaks==1.4.1