mirror of
https://github.com/jumpserver/jumpserver.git
synced 2025-07-07 20:08:58 +00:00
feat(ops): Task 支持批量操作
This commit is contained in:
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 import viewsets, generics
|
||||||
from rest_framework.views import Response
|
from rest_framework.views import Response
|
||||||
|
|
||||||
|
from common.drf.api import JMSBulkModelViewSet
|
||||||
from common.permissions import IsOrgAdmin
|
from common.permissions import IsOrgAdmin
|
||||||
from common.serializers import CeleryTaskSerializer
|
from common.serializers import CeleryTaskSerializer
|
||||||
from ..models import Task, AdHoc, AdHocExecution
|
from ..models import Task, AdHoc, AdHocExecution
|
||||||
@ -22,7 +23,7 @@ __all__ = [
|
|||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
class TaskViewSet(viewsets.ModelViewSet):
|
class TaskViewSet(JMSBulkModelViewSet):
|
||||||
queryset = Task.objects.all()
|
queryset = Task.objects.all()
|
||||||
filter_fields = ("name",)
|
filter_fields = ("name",)
|
||||||
search_fields = filter_fields
|
search_fields = filter_fields
|
||||||
|
@ -3,6 +3,7 @@ from __future__ import unicode_literals
|
|||||||
from rest_framework import serializers
|
from rest_framework import serializers
|
||||||
from django.shortcuts import reverse
|
from django.shortcuts import reverse
|
||||||
|
|
||||||
|
from orgs.mixins.serializers import BulkOrgResourceModelSerializer
|
||||||
from ..models import Task, AdHoc, AdHocExecution, CommandExecution
|
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')
|
summary = serializers.ReadOnlyField(source='history_summary')
|
||||||
latest_execution = AdHocExecutionExcludeResultSerializer(read_only=True)
|
latest_execution = AdHocExecutionExcludeResultSerializer(read_only=True)
|
||||||
|
|
||||||
|
@ -3,13 +3,16 @@ from __future__ import unicode_literals
|
|||||||
|
|
||||||
from django.urls import path
|
from django.urls import path
|
||||||
from rest_framework.routers import DefaultRouter
|
from rest_framework.routers import DefaultRouter
|
||||||
|
from rest_framework_bulk.routes import BulkRouter
|
||||||
from .. import api
|
from .. import api
|
||||||
|
|
||||||
|
|
||||||
app_name = "ops"
|
app_name = "ops"
|
||||||
|
|
||||||
router = DefaultRouter()
|
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', api.AdHocViewSet, 'adhoc')
|
||||||
router.register(r'adhoc-executions', api.AdHocRunHistoryViewSet, 'execution')
|
router.register(r'adhoc-executions', api.AdHocRunHistoryViewSet, 'execution')
|
||||||
router.register(r'command-executions', api.CommandExecutionViewSet, 'command-execution')
|
router.register(r'command-executions', api.CommandExecutionViewSet, 'command-execution')
|
||||||
@ -22,3 +25,4 @@ urlpatterns = [
|
|||||||
]
|
]
|
||||||
|
|
||||||
urlpatterns += router.urls
|
urlpatterns += router.urls
|
||||||
|
urlpatterns += bulk_router.urls
|
||||||
|
Loading…
Reference in New Issue
Block a user