Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
J
jumpserver
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ops
jumpserver
Commits
9bddc29d
Commit
9bddc29d
authored
Sep 29, 2018
by
ibuler
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[Update] 暂时不存status数据
parent
d68a4d9c
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
13 deletions
+13
-13
serializers.py
apps/terminal/serializers.py
+10
-13
terminal.py
apps/terminal/views/terminal.py
+3
-0
No files found.
apps/terminal/serializers.py
View file @
9bddc29d
# -*- coding: utf-8 -*-
#
from
django.core.cache
import
cache
from
django.utils
import
timezone
from
rest_framework
import
serializers
from
rest_framework_bulk.serializers
import
BulkListSerializer
...
...
@@ -28,19 +29,8 @@ class TerminalSerializer(serializers.ModelSerializer):
@staticmethod
def
get_is_alive
(
obj
):
try
:
status
=
obj
.
status_set
.
latest
()
except
Status
.
DoesNotExist
:
status
=
None
if
not
status
:
return
False
delta
=
timezone
.
now
()
-
status
.
date_created
if
delta
<
timezone
.
timedelta
(
seconds
=
600
):
return
True
else
:
return
False
key
=
StatusSerializer
.
CACHE_KEY_PREFIX
+
str
(
obj
.
id
)
return
cache
.
get
(
key
)
class
SessionSerializer
(
BulkSerializerMixin
,
serializers
.
ModelSerializer
):
...
...
@@ -57,11 +47,18 @@ class SessionSerializer(BulkSerializerMixin, serializers.ModelSerializer):
class
StatusSerializer
(
serializers
.
ModelSerializer
):
CACHE_KEY_PREFIX
=
'terminal_status_'
class
Meta
:
fields
=
'__all__'
model
=
Status
def
create
(
self
,
validated_data
):
terminal_id
=
str
(
validated_data
[
'terminal'
]
.
id
)
key
=
self
.
CACHE_KEY_PREFIX
+
terminal_id
cache
.
set
(
key
,
1
,
60
)
return
validated_data
class
TaskSerializer
(
BulkSerializerMixin
,
serializers
.
ModelSerializer
):
...
...
apps/terminal/views/terminal.py
View file @
9bddc29d
...
...
@@ -93,6 +93,9 @@ class TerminalAcceptView(SuperUserRequiredMixin, JSONResponseMixin, UpdateView):
class
TerminalConnectView
(
LoginRequiredMixin
,
SuperUserRequiredMixin
,
DetailView
):
"""
Abandon
"""
template_name
=
'flash_message_standalone.html'
model
=
Terminal
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment