* fix: token 系统用户增加 protocol

* fix: 修复清除orphan session时同时清除对应的 session_task

* perf: 修改 connection token api

* fix: 修复无法获取系统角色绑定的问题

* perf: 增加 db terminal 及 magnus 组件

* perf: 修改 migrations

* fix: 修复AUTHENTICATION_BACKENDS相关的逻辑

* fix: 修改判断backend认证逻辑

* fix: 修复资产账号查看密码跳过mfa

* fix: 修复用户组授权权限错误

* feat: 支持COS对象存储

* feat: 升级依赖 jms_storage==0.0.42

* fix: 修复 koko api 问题

* feat: 修改存储翻译信息

* perf: 修改 ticket 权限

* fix: 修复获取资产授权系统用户 get_queryset

* perf: 抽取 ticket

* perf: 修改 cmd filter 的权限

* fix: 修改 ticket perm

* fix: 修复oidc依赖问题

Co-authored-by: Eric <xplzv@126.com>
Co-authored-by: ibuler <ibuler@qq.com>
Co-authored-by: 小冯 <xiaofeng@xiaofengdeMacBook-Pro.local>
Co-authored-by: feng626 <1304903146@qq.com>
This commit is contained in:
Jiangjie.Bai
2022-02-28 19:28:58 +08:00
committed by GitHub
parent edfca5eb24
commit 03afa4f974
33 changed files with 294 additions and 205 deletions

View File

@@ -1,7 +1,9 @@
# -*- coding: utf-8 -*-
#
import datetime
import logging
from django.utils import timezone
from django.shortcuts import get_object_or_404
from rest_framework import viewsets, generics
from rest_framework.views import Response
@@ -28,14 +30,24 @@ class StatusViewSet(viewsets.ModelViewSet):
serializer.is_valid(raise_exception=True)
self.handle_sessions()
self.perform_create(serializer)
tasks = self.request.user.terminal.task_set.filter(is_finished=False)
serializer = self.task_serializer_class(tasks, many=True)
return Response(serializer.data, status=201)
task_serializer = self.get_task_serializer()
return Response(task_serializer.data, status=201)
def handle_sessions(self):
session_ids = self.request.data.get('sessions', [])
Session.set_sessions_active(session_ids)
def perform_create(self, serializer):
serializer.validated_data.pop('sessions', None)
serializer.validated_data["terminal"] = self.request.user.terminal
return super().perform_create(serializer)
def get_task_serializer(self):
critical_time = timezone.now() - datetime.timedelta(minutes=10)
tasks = self.request.user.terminal.task_set.filter(is_finished=False, date_created__gte=critical_time)
serializer = self.task_serializer_class(tasks, many=True)
return serializer
def get_queryset(self):
terminal_id = self.kwargs.get("terminal", None)
if terminal_id:
@@ -43,11 +55,6 @@ class StatusViewSet(viewsets.ModelViewSet):
return terminal.status_set.all()
return super().get_queryset()
def perform_create(self, serializer):
serializer.validated_data.pop('sessions', None)
serializer.validated_data["terminal"] = self.request.user.terminal
return super().perform_create(serializer)
class ComponentsMetricsAPIView(generics.GenericAPIView):
""" 返回汇总组件指标数据 """