diff --git a/apps/common/mixins/api.py b/apps/common/mixins/api.py index c49535ad6..bbabe9951 100644 --- a/apps/common/mixins/api.py +++ b/apps/common/mixins/api.py @@ -35,7 +35,6 @@ class SerializerMixin: serializer_class = self.serializer_classes.get( self.action, self.serializer_classes.get('default') ) - print(serializer_class) if serializer_class: return serializer_class return super().get_serializer_class() diff --git a/apps/perms/api/user_permission/common.py b/apps/perms/api/user_permission/common.py index 6af3bb6ba..17900a6bc 100644 --- a/apps/perms/api/user_permission/common.py +++ b/apps/perms/api/user_permission/common.py @@ -5,7 +5,7 @@ import uuid from django.shortcuts import get_object_or_404 from rest_framework.views import APIView, Response from rest_framework.generics import ( - ListAPIView, get_object_or_404, RetrieveAPIView + ListAPIView, get_object_or_404, RetrieveAPIView, DestroyAPIView ) from common.permissions import IsOrgAdminOrAppUser, IsOrgAdmin @@ -25,6 +25,7 @@ __all__ = [ 'UserGrantedAssetSystemUsersApi', 'ValidateUserAssetPermissionApi', 'GetUserAssetPermissionActionsApi', + 'UserAssetPermissionsCacheApi', ] @@ -117,3 +118,10 @@ class UserGrantedAssetSystemUsersApi(UserAssetPermissionMixin, ListAPIView): system_user.actions = actions 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) diff --git a/apps/perms/tests.py b/apps/perms/tests.py index 4fd76b0f2..344266b19 100644 --- a/apps/perms/tests.py +++ b/apps/perms/tests.py @@ -1,4 +1,3 @@ from django.test import TestCase from django.contrib.sessions.backends import file, db, cache -from django.contrib.auth.views import login \ No newline at end of file diff --git a/apps/perms/urls/asset_permission.py b/apps/perms/urls/asset_permission.py index c14db7c3e..ff8ac0c48 100644 --- a/apps/perms/urls/asset_permission.py +++ b/apps/perms/urls/asset_permission.py @@ -51,6 +51,11 @@ user_permission_urlpatterns = [ # Asset System users path('/assets//system-users/', api.UserGrantedAssetSystemUsersApi.as_view(), name='user-asset-system-users'), path('assets//system-users/', api.UserGrantedAssetSystemUsersApi.as_view(), name='my-asset-system-users'), + + # Expire user permission cache + path('/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 = [ diff --git a/apps/users/api/user.py b/apps/users/api/user.py index 97857c436..8729f4dcc 100644 --- a/apps/users/api/user.py +++ b/apps/users/api/user.py @@ -27,7 +27,7 @@ __all__ = [ class UserViewSet(CommonApiMixin, UserQuerysetMixin, BulkModelViewSet): - filter_fields = ('username', 'email', 'name', 'id') + filter_fields = ('username', 'email', 'name', 'id', 'source') search_fields = filter_fields serializer_class = serializers.UserSerializer permission_classes = (IsOrgAdmin, CanUpdateDeleteUser)