Commit dda34cb1 authored by ibuler's avatar ibuler

[Update] 修改使用Orgmodel view set

parent 4e85dd1d
...@@ -3,8 +3,8 @@ ...@@ -3,8 +3,8 @@
from rest_framework import generics from rest_framework import generics
from rest_framework_bulk import BulkModelViewSet
from orgs.mixins import OrgBulkModelViewSet
from ..hands import IsOrgAdmin, IsAppUser from ..hands import IsOrgAdmin, IsAppUser
from ..models import RemoteApp from ..models import RemoteApp
from ..serializers import RemoteAppSerializer, RemoteAppConnectionInfoSerializer from ..serializers import RemoteAppSerializer, RemoteAppConnectionInfoSerializer
...@@ -15,7 +15,7 @@ __all__ = [ ...@@ -15,7 +15,7 @@ __all__ = [
] ]
class RemoteAppViewSet(BulkModelViewSet): class RemoteAppViewSet(OrgBulkModelViewSet):
filter_fields = ('name',) filter_fields = ('name',)
search_fields = filter_fields search_fields = filter_fields
permission_classes = (IsOrgAdmin,) permission_classes = (IsOrgAdmin,)
......
...@@ -91,7 +91,6 @@ class AssetViewSet(LabelFilter, OrgBulkModelViewSet): ...@@ -91,7 +91,6 @@ class AssetViewSet(LabelFilter, OrgBulkModelViewSet):
return queryset return queryset
class AssetRefreshHardwareApi(generics.RetrieveAPIView): class AssetRefreshHardwareApi(generics.RetrieveAPIView):
""" """
Refresh asset hardware info Refresh asset hardware info
......
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# #
from rest_framework_bulk import BulkModelViewSet
from django.shortcuts import get_object_or_404 from django.shortcuts import get_object_or_404
from orgs.mixins import OrgBulkModelViewSet
from ..hands import IsOrgAdmin from ..hands import IsOrgAdmin
from ..models import CommandFilter, CommandFilterRule from ..models import CommandFilter, CommandFilterRule
from .. import serializers from .. import serializers
...@@ -12,7 +12,7 @@ from .. import serializers ...@@ -12,7 +12,7 @@ from .. import serializers
__all__ = ['CommandFilterViewSet', 'CommandFilterRuleViewSet'] __all__ = ['CommandFilterViewSet', 'CommandFilterRuleViewSet']
class CommandFilterViewSet(BulkModelViewSet): class CommandFilterViewSet(OrgBulkModelViewSet):
filter_fields = ("name",) filter_fields = ("name",)
search_fields = filter_fields search_fields = filter_fields
permission_classes = (IsOrgAdmin,) permission_classes = (IsOrgAdmin,)
...@@ -20,7 +20,7 @@ class CommandFilterViewSet(BulkModelViewSet): ...@@ -20,7 +20,7 @@ class CommandFilterViewSet(BulkModelViewSet):
serializer_class = serializers.CommandFilterSerializer serializer_class = serializers.CommandFilterSerializer
class CommandFilterRuleViewSet(BulkModelViewSet): class CommandFilterRuleViewSet(OrgBulkModelViewSet):
filter_fields = ("content",) filter_fields = ("content",)
search_fields = filter_fields search_fields = filter_fields
permission_classes = (IsOrgAdmin,) permission_classes = (IsOrgAdmin,)
......
# ~*~ coding: utf-8 ~*~ # ~*~ coding: utf-8 ~*~
from rest_framework_bulk import BulkModelViewSet
from rest_framework.views import APIView, Response from rest_framework.views import APIView, Response
from django.views.generic.detail import SingleObjectMixin from django.views.generic.detail import SingleObjectMixin
from common.utils import get_logger from common.utils import get_logger
from common.permissions import IsOrgAdmin, IsOrgAdminOrAppUser from common.permissions import IsOrgAdmin, IsOrgAdminOrAppUser
from orgs.mixins import OrgBulkModelViewSet
from ..models import Domain, Gateway from ..models import Domain, Gateway
from .. import serializers from .. import serializers
...@@ -14,7 +14,7 @@ logger = get_logger(__file__) ...@@ -14,7 +14,7 @@ logger = get_logger(__file__)
__all__ = ['DomainViewSet', 'GatewayViewSet', "GatewayTestConnectionApi"] __all__ = ['DomainViewSet', 'GatewayViewSet', "GatewayTestConnectionApi"]
class DomainViewSet(BulkModelViewSet): class DomainViewSet(OrgBulkModelViewSet):
queryset = Domain.objects.all() queryset = Domain.objects.all()
permission_classes = (IsOrgAdmin,) permission_classes = (IsOrgAdmin,)
serializer_class = serializers.DomainSerializer serializer_class = serializers.DomainSerializer
...@@ -34,7 +34,7 @@ class DomainViewSet(BulkModelViewSet): ...@@ -34,7 +34,7 @@ class DomainViewSet(BulkModelViewSet):
return super().get_permissions() return super().get_permissions()
class GatewayViewSet(BulkModelViewSet): class GatewayViewSet(OrgBulkModelViewSet):
filter_fields = ("domain__name", "name", "username", "ip", "domain") filter_fields = ("domain__name", "name", "username", "ip", "domain")
search_fields = filter_fields search_fields = filter_fields
queryset = Gateway.objects.all() queryset = Gateway.objects.all()
......
...@@ -398,7 +398,7 @@ REST_FRAMEWORK = { ...@@ -398,7 +398,7 @@ REST_FRAMEWORK = {
'SEARCH_PARAM': "search", 'SEARCH_PARAM': "search",
'DATETIME_FORMAT': '%Y-%m-%d %H:%M:%S %z', 'DATETIME_FORMAT': '%Y-%m-%d %H:%M:%S %z',
'DATETIME_INPUT_FORMATS': ['iso-8601', '%Y-%m-%d %H:%M:%S %z'], 'DATETIME_INPUT_FORMATS': ['iso-8601', '%Y-%m-%d %H:%M:%S %z'],
# 'DEFAULT_PAGINATION_CLASS': 'rest_framework.pagination.LimitOffsetPagination', 'DEFAULT_PAGINATION_CLASS': 'rest_framework.pagination.LimitOffsetPagination',
# 'PAGE_SIZE': 15 # 'PAGE_SIZE': 15
} }
......
...@@ -2,7 +2,6 @@ ...@@ -2,7 +2,6 @@
# #
from rest_framework import generics from rest_framework import generics
from rest_framework_bulk import BulkModelViewSet
from ..serializers import ( from ..serializers import (
UserGroupSerializer, UserGroupSerializer,
...@@ -10,14 +9,14 @@ from ..serializers import ( ...@@ -10,14 +9,14 @@ from ..serializers import (
UserGroupUpdateMemberSerializer, UserGroupUpdateMemberSerializer,
) )
from ..models import UserGroup from ..models import UserGroup
from orgs.mixins import OrgBulkModelViewSet
from common.permissions import IsOrgAdmin from common.permissions import IsOrgAdmin
from common.mixins import IDInCacheFilterMixin
__all__ = ['UserGroupViewSet', 'UserGroupUpdateUserApi'] __all__ = ['UserGroupViewSet', 'UserGroupUpdateUserApi']
class UserGroupViewSet(IDInCacheFilterMixin, BulkModelViewSet): class UserGroupViewSet(OrgBulkModelViewSet):
filter_fields = ("name",) filter_fields = ("name",)
search_fields = filter_fields search_fields = filter_fields
queryset = UserGroup.objects.all() queryset = UserGroup.objects.all()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment