mirror of https://github.com/jumpserver/jumpserver
commit
4517a92b2b
|
@ -2,22 +2,26 @@
|
||||||
#
|
#
|
||||||
from rest_framework.viewsets import GenericViewSet
|
from rest_framework.viewsets import GenericViewSet
|
||||||
from rest_framework.mixins import ListModelMixin
|
from rest_framework.mixins import ListModelMixin
|
||||||
from django.db.models import Q
|
|
||||||
|
|
||||||
from common.mixins.api import CommonApiMixin
|
from common.mixins.api import CommonApiMixin
|
||||||
from common.permissions import IsOrgAdminOrAppUser, IsOrgAuditor, IsOrgAdmin
|
from common.permissions import IsOrgAdminOrAppUser, IsOrgAuditor, IsOrgAdmin
|
||||||
from common.drf.filters import DatetimeRangeFilter
|
from common.drf.filters import DatetimeRangeFilter
|
||||||
from orgs.mixins.api import OrgModelViewSet
|
from orgs.mixins.api import OrgGenericViewSet
|
||||||
from orgs.utils import current_org
|
from orgs.utils import current_org
|
||||||
from .models import FTPLog, UserLoginLog
|
from .models import FTPLog, UserLoginLog
|
||||||
from .serializers import FTPLogSerializer, UserLoginLogSerializer
|
from .serializers import FTPLogSerializer, UserLoginLogSerializer
|
||||||
|
|
||||||
|
|
||||||
class FTPLogViewSet(OrgModelViewSet):
|
class FTPLogViewSet(ListModelMixin, OrgGenericViewSet):
|
||||||
model = FTPLog
|
model = FTPLog
|
||||||
serializer_class = FTPLogSerializer
|
serializer_class = FTPLogSerializer
|
||||||
permission_classes = (IsOrgAdminOrAppUser | IsOrgAuditor,)
|
permission_classes = (IsOrgAdminOrAppUser | IsOrgAuditor,)
|
||||||
http_method_names = ['get', 'post', 'head', 'options']
|
extra_filter_backends = [DatetimeRangeFilter]
|
||||||
|
date_range_filter_fields = [
|
||||||
|
('date_start', ('date_from', 'date_to'))
|
||||||
|
]
|
||||||
|
filterset_fields = ['user', 'asset', 'system_user']
|
||||||
|
search_fields = ['filename']
|
||||||
|
|
||||||
|
|
||||||
class UserLoginLogViewSet(CommonApiMixin,
|
class UserLoginLogViewSet(CommonApiMixin,
|
||||||
|
|
|
@ -11,7 +11,10 @@ class FTPLogSerializer(serializers.ModelSerializer):
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
model = models.FTPLog
|
model = models.FTPLog
|
||||||
fields = '__all__'
|
fields = (
|
||||||
|
'id', 'user', 'remote_addr', 'asset', 'system_user',
|
||||||
|
'operate', 'filename', 'is_success', 'date_start'
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
class UserLoginLogSerializer(serializers.ModelSerializer):
|
class UserLoginLogSerializer(serializers.ModelSerializer):
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
#
|
#
|
||||||
from django.shortcuts import get_object_or_404
|
from django.shortcuts import get_object_or_404
|
||||||
from rest_framework.viewsets import ModelViewSet
|
from rest_framework.viewsets import ModelViewSet, GenericViewSet
|
||||||
from rest_framework_bulk import BulkModelViewSet
|
from rest_framework_bulk import BulkModelViewSet
|
||||||
from common.mixins import CommonApiMixin
|
from common.mixins import CommonApiMixin
|
||||||
|
|
||||||
|
@ -44,6 +44,10 @@ class OrgModelViewSet(CommonApiMixin, OrgQuerySetMixin, ModelViewSet):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class OrgGenericViewSet(CommonApiMixin, OrgQuerySetMixin, GenericViewSet):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
class OrgBulkModelViewSet(CommonApiMixin, OrgQuerySetMixin, BulkModelViewSet):
|
class OrgBulkModelViewSet(CommonApiMixin, OrgQuerySetMixin, BulkModelViewSet):
|
||||||
def allow_bulk_destroy(self, qs, filtered):
|
def allow_bulk_destroy(self, qs, filtered):
|
||||||
qs_count = qs.count()
|
qs_count = qs.count()
|
||||||
|
|
Loading…
Reference in New Issue