mirror of
https://github.com/jumpserver/jumpserver.git
synced 2025-08-31 23:20:37 +00:00
Merge: v3 to dev (#9160)
* fix: 修改 ConnectionTokenSecretSerializer * perf: connect token secret (#9155) Co-authored-by: feng <1304903146@qq.com> Co-authored-by: Jiangjie.Bai <bugatti_it@163.com> * feat: 作业迁移至个人级别 * perf: asset enabled (#9157) Co-authored-by: feng <1304903146@qq.com> * perf: 修改ConnectionTokenSecret Gateway数据结构; 修改Domain Gateway Model方法 * perf: ConnectionTokenSecret 返回 domain 信息 * refactor: 移动 Gateway Model 到 asset 目录下 * refactor: 移动 Gateway Model 单独到 gateway 文件中 * perf: 修改 GatewaySerializer 目录 * perf: 修改 GatewaySerializer 目录 Co-authored-by: fit2bot <68588906+fit2bot@users.noreply.github.com> Co-authored-by: feng <1304903146@qq.com> Co-authored-by: Aaron3S <chenyang@fit2cloud.com>
This commit is contained in:
@@ -1,9 +1,9 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
|
||||
from rest_framework import viewsets
|
||||
from rest_framework_bulk import BulkModelViewSet
|
||||
|
||||
from orgs.mixins.api import OrgBulkModelViewSet
|
||||
from common.mixins import CommonApiMixin
|
||||
from ..models import AdHoc
|
||||
from ..serializers import (
|
||||
AdHocSerializer
|
||||
@@ -14,7 +14,9 @@ __all__ = [
|
||||
]
|
||||
|
||||
|
||||
class AdHocViewSet(OrgBulkModelViewSet):
|
||||
class AdHocViewSet(CommonApiMixin, BulkModelViewSet):
|
||||
serializer_class = AdHocSerializer
|
||||
permission_classes = ()
|
||||
model = AdHoc
|
||||
|
||||
def get_queryset(self):
|
||||
return AdHoc.objects.filter(creator=self.request.user)
|
||||
|
@@ -1,12 +1,13 @@
|
||||
from rest_framework import viewsets
|
||||
from rest_framework_bulk import BulkModelViewSet
|
||||
|
||||
from common.mixins import CommonApiMixin
|
||||
from ops.models import Job, JobExecution
|
||||
from ops.serializers.job import JobSerializer, JobExecutionSerializer
|
||||
|
||||
__all__ = ['JobViewSet', 'JobExecutionViewSet']
|
||||
|
||||
from ops.tasks import run_ops_job_execution
|
||||
from orgs.mixins.api import OrgBulkModelViewSet
|
||||
|
||||
|
||||
def set_task_to_serializer_data(serializer, task):
|
||||
@@ -15,13 +16,12 @@ def set_task_to_serializer_data(serializer, task):
|
||||
setattr(serializer, "_data", data)
|
||||
|
||||
|
||||
class JobViewSet(OrgBulkModelViewSet):
|
||||
class JobViewSet(CommonApiMixin, BulkModelViewSet):
|
||||
serializer_class = JobSerializer
|
||||
model = Job
|
||||
permission_classes = ()
|
||||
|
||||
def get_queryset(self):
|
||||
query_set = super().get_queryset()
|
||||
query_set = Job.objects.filter(creator=self.request.user)
|
||||
if self.action != 'retrieve':
|
||||
return query_set.filter(instant=False)
|
||||
return query_set
|
||||
@@ -45,11 +45,10 @@ class JobViewSet(OrgBulkModelViewSet):
|
||||
set_task_to_serializer_data(serializer, task)
|
||||
|
||||
|
||||
class JobExecutionViewSet(OrgBulkModelViewSet):
|
||||
class JobExecutionViewSet(CommonApiMixin, BulkModelViewSet):
|
||||
serializer_class = JobExecutionSerializer
|
||||
http_method_names = ('get', 'post', 'head', 'options',)
|
||||
permission_classes = ()
|
||||
model = JobExecution
|
||||
|
||||
def perform_create(self, serializer):
|
||||
instance = serializer.save()
|
||||
@@ -57,7 +56,8 @@ class JobExecutionViewSet(OrgBulkModelViewSet):
|
||||
set_task_to_serializer_data(serializer, task)
|
||||
|
||||
def get_queryset(self):
|
||||
query_set = super().get_queryset()
|
||||
query_set = JobExecution.objects.filter(creator=self.request.user)
|
||||
query_set = query_set.filter(creator=self.request.user)
|
||||
job_id = self.request.query_params.get('job_id')
|
||||
if job_id:
|
||||
query_set = query_set.filter(job_id=job_id)
|
||||
|
@@ -2,7 +2,9 @@ import os
|
||||
import zipfile
|
||||
|
||||
from django.conf import settings
|
||||
from rest_framework_bulk import BulkModelViewSet
|
||||
|
||||
from common.mixins import CommonApiMixin
|
||||
from orgs.mixins.api import OrgBulkModelViewSet
|
||||
from ..exception import PlaybookNoValidEntry
|
||||
from ..models import Playbook
|
||||
@@ -17,7 +19,7 @@ def unzip_playbook(src, dist):
|
||||
fz.extract(file, dist)
|
||||
|
||||
|
||||
class PlaybookViewSet(OrgBulkModelViewSet):
|
||||
class PlaybookViewSet(CommonApiMixin, BulkModelViewSet):
|
||||
serializer_class = PlaybookSerializer
|
||||
permission_classes = ()
|
||||
model = Playbook
|
||||
|
Reference in New Issue
Block a user