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
f4fc7573
Commit
f4fc7573
authored
Oct 22, 2019
by
jym503558564
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[Bugfix] 修改导出登录日志的日期选择从开始时间的00:00:00,到结束时间的23:59:59
parent
334e3bef
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
13 additions
and
7 deletions
+13
-7
models.py
apps/audits/models.py
+7
-3
login_log_list.html
apps/audits/templates/audits/login_log_list.html
+2
-2
views.py
apps/audits/views.py
+4
-2
No files found.
apps/audits/models.py
View file @
f4fc7573
...
...
@@ -88,11 +88,15 @@ class UserLoginLog(models.Model):
datetime
=
models
.
DateTimeField
(
default
=
timezone
.
now
,
verbose_name
=
_
(
'Date login'
))
@classmethod
def
get_login_logs
(
cls
,
date_f
orm
=
None
,
date_to
=
None
,
user
=
None
,
keyword
=
None
):
def
get_login_logs
(
cls
,
date_f
rom
=
None
,
date_to
=
None
,
user
=
None
,
keyword
=
None
,
date_format
=
None
):
login_logs
=
cls
.
objects
.
all
()
if
date_form
and
date_to
:
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'
)
login_logs
=
login_logs
.
filter
(
datetime__gt
=
date_form
,
datetime__lt
=
date_to
datetime__gt
e
=
date_from
,
datetime__lte
=
date_to
)
if
user
:
login_logs
=
login_logs
.
filter
(
username
=
user
)
...
...
apps/audits/templates/audits/login_log_list.html
View file @
f4fc7573
...
...
@@ -121,7 +121,7 @@
});
})
.
on
(
'click'
,
'.btn_export'
,
function
()
{
var
date_f
or
m
=
$
(
'#id_date_from'
).
val
();
var
date_f
ro
m
=
$
(
'#id_date_from'
).
val
();
var
date_to
=
$
(
'#id_date_to'
).
val
();
var
user
=
$
(
'.select2 option:selected'
).
val
();
var
keyword
=
$
(
'#search'
).
val
();
...
...
@@ -129,7 +129,7 @@
url
:
"{% url "
audits
:
login
-
log
-
export
" %}"
,
method
:
'POST'
,
data
:
JSON
.
stringify
({
'date_f
orm'
:
date_for
m
,
'date_f
rom'
:
date_fro
m
,
'date_to'
:
date_to
,
'user'
:
user
,
'keyword'
:
keyword
...
...
apps/audits/views.py
View file @
f4fc7573
...
...
@@ -255,6 +255,7 @@ class CommandExecutionListView(UserCommandExecutionListView):
@method_decorator
(
csrf_exempt
,
name
=
'dispatch'
)
class
LoginLogExportView
(
PermissionsMixin
,
View
):
permission_classes
=
[
IsValidUser
]
date_format
=
'
%
Y-
%
m-
%
d'
def
get
(
self
,
request
):
fields
=
[
...
...
@@ -273,13 +274,14 @@ class LoginLogExportView(PermissionsMixin, View):
def
post
(
self
,
request
):
try
:
date_f
orm
=
json
.
loads
(
request
.
body
)
.
get
(
'date_for
m'
,
[])
date_f
rom
=
json
.
loads
(
request
.
body
)
.
get
(
'date_fro
m'
,
[])
date_to
=
json
.
loads
(
request
.
body
)
.
get
(
'date_to'
,
[])
user
=
json
.
loads
(
request
.
body
)
.
get
(
'user'
,
[])
keyword
=
json
.
loads
(
request
.
body
)
.
get
(
'keyword'
,
[])
login_logs
=
UserLoginLog
.
get_login_logs
(
date_form
=
date_form
,
date_to
=
date_to
,
user
=
user
,
keyword
=
keyword
)
date_from
=
date_from
,
date_to
=
date_to
,
user
=
user
,
keyword
=
keyword
,
date_format
=
self
.
date_format
)
except
ValueError
:
return
HttpResponse
(
'Json object not valid'
,
status
=
400
)
spm
=
uuid
.
uuid4
()
.
hex
...
...
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