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
950358f5
Commit
950358f5
authored
Oct 22, 2019
by
BaiJiangJie
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[Update] 优化登录日志时间范围
parent
3c7fa1b6
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
4 additions
and
6 deletions
+4
-6
models.py
apps/audits/models.py
+3
-5
views.py
apps/audits/views.py
+1
-1
No files found.
apps/audits/models.py
View file @
950358f5
...
...
@@ -88,13 +88,11 @@ class UserLoginLog(models.Model):
datetime
=
models
.
DateTimeField
(
default
=
timezone
.
now
,
verbose_name
=
_
(
'Date login'
))
@classmethod
def
get_login_logs
(
cls
,
date_from
=
None
,
date_to
=
None
,
user
=
None
,
keyword
=
None
,
date_format
=
None
):
def
get_login_logs
(
cls
,
date_from
=
None
,
date_to
=
None
,
user
=
None
,
keyword
=
None
):
login_logs
=
cls
.
objects
.
all
()
if
date_from
and
date_to
:
date_from
=
timezone
.
datetime
.
strptime
(
date_from
,
date_format
)
date_to
=
timezone
.
datetime
.
strptime
(
date_to
+
' 23:59:59'
,
date_format
+
'
%
H:
%
M:
%
S'
)
date_from
=
"{} {}"
.
format
(
date_from
,
'00:00:00'
)
date_to
=
"{} {}"
.
format
(
date_to
,
'23:59:59'
)
login_logs
=
login_logs
.
filter
(
datetime__gte
=
date_from
,
datetime__lte
=
date_to
)
...
...
apps/audits/views.py
View file @
950358f5
...
...
@@ -282,7 +282,7 @@ class LoginLogExportView(PermissionsMixin, View):
login_logs
=
UserLoginLog
.
get_login_logs
(
date_from
=
date_from
,
date_to
=
date_to
,
user
=
user
,
keyword
=
keyword
,
date_format
=
self
.
date_format
keyword
=
keyword
,
)
except
ValueError
:
return
HttpResponse
(
'Json object not valid'
,
status
=
400
)
...
...
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