mirror of https://github.com/jumpserver/jumpserver
feat(ops): Task 支持批量操作
parent
231332585d
commit
2b4f8bd11c
|
@ -5,6 +5,7 @@ from django.shortcuts import get_object_or_404
|
|||
from rest_framework import viewsets, generics
|
||||
from rest_framework.views import Response
|
||||
|
||||
from common.drf.api import JMSBulkModelViewSet
|
||||
from common.permissions import IsOrgAdmin
|
||||
from common.serializers import CeleryTaskSerializer
|
||||
from ..models import Task, AdHoc, AdHocExecution
|
||||
|
@ -22,7 +23,7 @@ __all__ = [
|
|||
]
|
||||
|
||||
|
||||
class TaskViewSet(viewsets.ModelViewSet):
|
||||
class TaskViewSet(JMSBulkModelViewSet):
|
||||
queryset = Task.objects.all()
|
||||
filter_fields = ("name",)
|
||||
search_fields = filter_fields
|
||||
|
|
|
@ -3,6 +3,7 @@ from __future__ import unicode_literals
|
|||
from rest_framework import serializers
|
||||
from django.shortcuts import reverse
|
||||
|
||||
from orgs.mixins.serializers import BulkOrgResourceModelSerializer
|
||||
from ..models import Task, AdHoc, AdHocExecution, CommandExecution
|
||||
|
||||
|
||||
|
@ -45,7 +46,7 @@ class AdHocExecutionExcludeResultSerializer(AdHocExecutionSerializer):
|
|||
]
|
||||
|
||||
|
||||
class TaskSerializer(serializers.ModelSerializer):
|
||||
class TaskSerializer(BulkOrgResourceModelSerializer):
|
||||
summary = serializers.ReadOnlyField(source='history_summary')
|
||||
latest_execution = AdHocExecutionExcludeResultSerializer(read_only=True)
|
||||
|
||||
|
|
|
@ -3,13 +3,16 @@ from __future__ import unicode_literals
|
|||
|
||||
from django.urls import path
|
||||
from rest_framework.routers import DefaultRouter
|
||||
from rest_framework_bulk.routes import BulkRouter
|
||||
from .. import api
|
||||
|
||||
|
||||
app_name = "ops"
|
||||
|
||||
router = DefaultRouter()
|
||||
router.register(r'tasks', api.TaskViewSet, 'task')
|
||||
bulk_router = BulkRouter()
|
||||
|
||||
bulk_router.register(r'tasks', api.TaskViewSet, 'task')
|
||||
router.register(r'adhoc', api.AdHocViewSet, 'adhoc')
|
||||
router.register(r'adhoc-executions', api.AdHocRunHistoryViewSet, 'execution')
|
||||
router.register(r'command-executions', api.CommandExecutionViewSet, 'command-execution')
|
||||
|
@ -22,3 +25,4 @@ urlpatterns = [
|
|||
]
|
||||
|
||||
urlpatterns += router.urls
|
||||
urlpatterns += bulk_router.urls
|
||||
|
|
Loading…
Reference in New Issue