pull/4047/head
Bai 5 years ago
commit 566419cac4

@ -35,7 +35,6 @@ class SerializerMixin:
serializer_class = self.serializer_classes.get( serializer_class = self.serializer_classes.get(
self.action, self.serializer_classes.get('default') self.action, self.serializer_classes.get('default')
) )
print(serializer_class)
if serializer_class: if serializer_class:
return serializer_class return serializer_class
return super().get_serializer_class() return super().get_serializer_class()

@ -5,7 +5,7 @@ import uuid
from django.shortcuts import get_object_or_404 from django.shortcuts import get_object_or_404
from rest_framework.views import APIView, Response from rest_framework.views import APIView, Response
from rest_framework.generics import ( from rest_framework.generics import (
ListAPIView, get_object_or_404, RetrieveAPIView ListAPIView, get_object_or_404, RetrieveAPIView, DestroyAPIView
) )
from common.permissions import IsOrgAdminOrAppUser, IsOrgAdmin from common.permissions import IsOrgAdminOrAppUser, IsOrgAdmin
@ -25,6 +25,7 @@ __all__ = [
'UserGrantedAssetSystemUsersApi', 'UserGrantedAssetSystemUsersApi',
'ValidateUserAssetPermissionApi', 'ValidateUserAssetPermissionApi',
'GetUserAssetPermissionActionsApi', 'GetUserAssetPermissionActionsApi',
'UserAssetPermissionsCacheApi',
] ]
@ -117,3 +118,10 @@ class UserGrantedAssetSystemUsersApi(UserAssetPermissionMixin, ListAPIView):
system_user.actions = actions system_user.actions = actions
return system_users return system_users
class UserAssetPermissionsCacheApi(UserAssetPermissionMixin, DestroyAPIView):
permission_classes = (IsOrgAdmin,)
def destroy(self, request, *args, **kwargs):
self.util.expire_user_tree_cache()
return Response(status=204)

@ -1,4 +1,3 @@
from django.test import TestCase from django.test import TestCase
from django.contrib.sessions.backends import file, db, cache from django.contrib.sessions.backends import file, db, cache
from django.contrib.auth.views import login

@ -51,6 +51,11 @@ user_permission_urlpatterns = [
# Asset System users # Asset System users
path('<uuid:pk>/assets/<uuid:asset_id>/system-users/', api.UserGrantedAssetSystemUsersApi.as_view(), name='user-asset-system-users'), path('<uuid:pk>/assets/<uuid:asset_id>/system-users/', api.UserGrantedAssetSystemUsersApi.as_view(), name='user-asset-system-users'),
path('assets/<uuid:asset_id>/system-users/', api.UserGrantedAssetSystemUsersApi.as_view(), name='my-asset-system-users'), path('assets/<uuid:asset_id>/system-users/', api.UserGrantedAssetSystemUsersApi.as_view(), name='my-asset-system-users'),
# Expire user permission cache
path('<uuid:pk>/asset-permissions/cache/', api.UserAssetPermissionsCacheApi.as_view(),
name='user-asset-permission-cache'),
path('asset-permissions/cache/', api.UserAssetPermissionsCacheApi.as_view(), name='my-asset-permission-cache'),
] ]
user_group_permission_urlpatterns = [ user_group_permission_urlpatterns = [

@ -27,7 +27,7 @@ __all__ = [
class UserViewSet(CommonApiMixin, UserQuerysetMixin, BulkModelViewSet): class UserViewSet(CommonApiMixin, UserQuerysetMixin, BulkModelViewSet):
filter_fields = ('username', 'email', 'name', 'id') filter_fields = ('username', 'email', 'name', 'id', 'source')
search_fields = filter_fields search_fields = filter_fields
serializer_class = serializers.UserSerializer serializer_class = serializers.UserSerializer
permission_classes = (IsOrgAdmin, CanUpdateDeleteUser) permission_classes = (IsOrgAdmin, CanUpdateDeleteUser)

Loading…
Cancel
Save