diff --git a/apps/orgs/api.py b/apps/orgs/api.py index 913693d67..b49bb08db 100644 --- a/apps/orgs/api.py +++ b/apps/orgs/api.py @@ -1,20 +1,20 @@ # -*- coding: utf-8 -*- # -from django.utils.translation import ugettext as _ from django.conf import settings -from rest_framework_bulk import BulkModelViewSet -from rest_framework.generics import RetrieveAPIView +from django.utils.translation import ugettext as _ from rest_framework.exceptions import PermissionDenied +from rest_framework.generics import RetrieveAPIView -from common.utils import get_logger -from common.permissions import IsValidUser -from users.models import User, UserGroup from assets.models import ( Asset, Domain, Label, Node, ) -from perms.models import AssetPermission +from common.api import JMSBulkModelViewSet +from common.permissions import IsValidUser +from common.utils import get_logger from orgs.utils import current_org, tmp_to_root_org +from perms.models import AssetPermission +from users.models import User, UserGroup from .models import Organization from .serializers import ( OrgSerializer, CurrentOrgSerializer @@ -29,7 +29,7 @@ org_related_models = [ ] -class OrgViewSet(BulkModelViewSet): +class OrgViewSet(JMSBulkModelViewSet): filterset_fields = ('name',) search_fields = ('name', 'comment') queryset = Organization.objects.all() diff --git a/apps/perms/api/user_permission/assets.py b/apps/perms/api/user_permission/assets.py index 60970551d..98339fde3 100644 --- a/apps/perms/api/user_permission/assets.py +++ b/apps/perms/api/user_permission/assets.py @@ -26,6 +26,7 @@ logger = get_logger(__name__) class BaseUserPermedAssetsApi(SelfOrPKUserMixin, ListAPIView): ordering = ('name',) search_fields = ('name', 'address', 'comment') + ordering_fields = ("name", "address") filterset_class = AssetFilterSet serializer_class = serializers.AssetPermedSerializer only_fields = serializers.AssetPermedSerializer.Meta.only_fields diff --git a/apps/terminal/api/session/task.py b/apps/terminal/api/session/task.py index 80fee6097..8daeeb4a7 100644 --- a/apps/terminal/api/session/task.py +++ b/apps/terminal/api/session/task.py @@ -1,22 +1,23 @@ # -*- coding: utf-8 -*- # import logging -from rest_framework.views import APIView, Response -from rest_framework_bulk import BulkModelViewSet + from rest_framework import status from rest_framework.permissions import IsAuthenticated +from rest_framework.views import APIView, Response +from common.api import JMSBulkModelViewSet from common.utils import get_object_or_none from orgs.utils import tmp_to_root_org -from terminal.models import Session, Task from terminal import serializers +from terminal.models import Session, Task from terminal.utils import is_session_approver __all__ = ['TaskViewSet', 'KillSessionAPI', 'KillSessionForTicketAPI'] logger = logging.getLogger(__file__) -class TaskViewSet(BulkModelViewSet): +class TaskViewSet(JMSBulkModelViewSet): queryset = Task.objects.all() serializer_class = serializers.TaskSerializer filterset_fields = ('is_finished',) @@ -51,7 +52,7 @@ class KillSessionAPI(APIView): class KillSessionForTicketAPI(APIView): - permission_classes = (IsAuthenticated, ) + permission_classes = (IsAuthenticated,) def post(self, request, *args, **kwargs): session_ids = request.data