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
0848893f
Commit
0848893f
authored
Dec 26, 2017
by
ibuler
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[Bugfix] 修复时间日期搜索的bug,select2模块自适应长度
parent
3d705dbe
Hide whitespace changes
Inline
Side-by-side
Showing
32 changed files
with
139 additions
and
160 deletions
+139
-160
_system_user.html
apps/assets/templates/assets/_system_user.html
+1
-1
admin_user_create_update.html
apps/assets/templates/assets/admin_user_create_update.html
+2
-1
admin_user_detail.html
apps/assets/templates/assets/admin_user_detail.html
+1
-1
asset_bulk_update.html
apps/assets/templates/assets/asset_bulk_update.html
+1
-1
asset_create.html
apps/assets/templates/assets/asset_create.html
+1
-1
asset_group_create.html
apps/assets/templates/assets/asset_group_create.html
+1
-1
asset_group_detail.html
apps/assets/templates/assets/asset_group_detail.html
+1
-1
cluster_assets.html
apps/assets/templates/assets/cluster_assets.html
+1
-1
cluster_create_update.html
apps/assets/templates/assets/cluster_create_update.html
+5
-1
cluster_detail.html
apps/assets/templates/assets/cluster_detail.html
+1
-1
system_user_asset.html
apps/assets/templates/assets/system_user_asset.html
+1
-1
system_user_detail.html
apps/assets/templates/assets/system_user_detail.html
+1
-1
system_user_update.html
apps/assets/templates/assets/system_user_update.html
+2
-1
mixins.py
apps/common/mixins.py
+30
-3
task_list.html
apps/ops/templates/ops/task_list.html
+6
-3
views.py
apps/ops/views.py
+11
-23
asset_permission_create_update.html
...perms/templates/perms/asset_permission_create_update.html
+1
-1
asset_permission_detail.html
apps/perms/templates/perms/asset_permission_detail.html
+1
-1
command_list.html
apps/terminal/templates/terminal/command_list.html
+20
-15
session_list.html
apps/terminal/templates/terminal/session_list.html
+6
-3
terminal_update.html
apps/terminal/templates/terminal/terminal_update.html
+1
-1
command.py
apps/terminal/views/command.py
+9
-29
session.py
apps/terminal/views/session.py
+10
-29
_user.html
apps/users/templates/users/_user.html
+1
-1
login_log_list.html
apps/users/templates/users/login_log_list.html
+5
-3
user_bulk_update.html
apps/users/templates/users/user_bulk_update.html
+1
-1
user_detail.html
apps/users/templates/users/user_detail.html
+1
-1
user_granted_asset.html
apps/users/templates/users/user_granted_asset.html
+1
-1
user_group_create_update.html
apps/users/templates/users/user_group_create_update.html
+1
-1
user_group_detail.html
apps/users/templates/users/user_group_detail.html
+1
-1
user_group_granted_asset.html
apps/users/templates/users/user_group_granted_asset.html
+1
-1
login.py
apps/users/views/login.py
+13
-29
No files found.
apps/assets/templates/assets/_system_user.html
View file @
0848893f
...
...
@@ -90,7 +90,7 @@
}
}
$
(
document
).
ready
(
function
()
{
$
(
'.select2'
).
select2
();
$
(
'.select2'
).
select2
(
{
dropdownAutoWidth
:
true
,
width
:
'auto'
}
);
authFieldsDisplay
();
$
(
auto_generate_key
).
change
(
function
()
{
authFieldsDisplay
();
...
...
apps/assets/templates/assets/admin_user_create_update.html
View file @
0848893f
...
...
@@ -56,7 +56,7 @@
{% block custom_foot_js %}
<script>
$
(
document
).
ready
(
function
()
{
$
(
'.select2'
).
select2
();
$
(
'.select2'
).
select2
(
{
dropdownAutoWidth
:
true
,
width
:
'auto'
}
);
})
</script>
{% endblock %}
\ No newline at end of file
apps/assets/templates/assets/admin_user_detail.html
View file @
0848893f
...
...
@@ -157,7 +157,7 @@ function bindToCluster(clusters) {
jumpserver
.
cluster_selected
=
{};
$
(
document
).
ready
(
function
()
{
$
(
'.select2'
).
select2
(
)
.
on
(
'select2:select'
,
function
(
evt
)
{
$
(
'.select2'
).
select2
(
{
dropdownAutoWidth
:
true
,
width
:
'auto'
});
.
on
(
'select2:select'
,
function
(
evt
)
{
var
data
=
evt
.
params
.
data
;
jumpserver
.
cluster_selected
[
data
.
id
]
=
data
.
text
;
}).
on
(
'select2:unselect'
,
function
(
evt
)
{
...
...
apps/assets/templates/assets/asset_bulk_update.html
View file @
0848893f
...
...
@@ -30,7 +30,7 @@
{% block custom_foot_js %}
<script>
$
(
document
).
ready
(
function
()
{
$
(
'.select2'
).
select2
();
$
(
'.select2'
).
select2
(
{
dropdownAutoWidth
:
true
,
width
:
'auto'
}
);
}).
on
(
'click'
,
'.field-tag'
,
function
()
{
changeField
(
this
);
}).
on
(
'click'
,
'#change_all'
,
function
()
{
...
...
apps/assets/templates/assets/asset_create.html
View file @
0848893f
...
...
@@ -47,7 +47,7 @@
{% block custom_foot_js %}
<script>
$
(
document
).
ready
(
function
()
{
$
(
'.select2'
).
select2
();
$
(
'.select2'
).
select2
(
{
dropdownAutoWidth
:
true
,
width
:
'auto'
}
);
{
#
$
(
"#id_tags"
).
select2
({
#
}
{
#
tags
:
true
,
#
}
{
#
maximumSelectionLength
:
8
//最多能够选择的个数#}
...
...
apps/assets/templates/assets/asset_group_create.html
View file @
0848893f
...
...
@@ -81,7 +81,7 @@
{% block custom_foot_js %}
<script
type=
"text/javascript"
>
$
(
document
).
ready
(
function
()
{
$
(
'.select2'
).
select2
();
$
(
'.select2'
).
select2
(
{
dropdownAutoWidth
:
true
,
width
:
'auto'
}
);
$
(
'.select2-system-user'
).
select2
();
});
...
...
apps/assets/templates/assets/asset_group_detail.html
View file @
0848893f
...
...
@@ -184,7 +184,7 @@ function initTable() {
}
$
(
document
).
ready
(
function
()
{
$
(
'.select2'
).
select2
();
$
(
'.select2'
).
select2
(
{
dropdownAutoWidth
:
true
,
width
:
'auto'
}
);
$
(
'.select2.asset-select'
).
select2
()
.
on
(
'select2:select'
,
function
(
evt
)
{
...
...
apps/assets/templates/assets/cluster_assets.html
View file @
0848893f
...
...
@@ -181,7 +181,7 @@ function initTable() {
}
$
(
document
).
ready
(
function
()
{
$
(
'.select2'
).
select2
(
)
$
(
'.select2'
).
select2
(
{
dropdownAutoWidth
:
true
,
width
:
'auto'
});
.
on
(
"select2:select"
,
function
(
evt
)
{
var
data
=
evt
.
params
.
data
;
jumpserver
.
assets_selected
[
data
.
id
]
=
data
.
text
;
...
...
apps/assets/templates/assets/cluster_create_update.html
View file @
0848893f
...
...
@@ -69,7 +69,10 @@
{% block custom_foot_js %}
<script>
$
(
document
).
ready
(
function
()
{
$
(
'.select2'
).
select2
();
$
(
'.select2'
).
select2
({
dropdownAutoWidth
:
true
,
width
:
'auto'
});
})
</script>
{% endblock %}
\ No newline at end of file
apps/assets/templates/assets/cluster_detail.html
View file @
0848893f
...
...
@@ -151,7 +151,7 @@
<script>
$
(
document
).
ready
(
function
()
{
$
(
'.select2'
).
select2
();
$
(
'.select2'
).
select2
(
{
dropdownAutoWidth
:
true
,
width
:
'auto'
}
);
})
.
on
(
'click'
,
'.btn-delete-cluster'
,
function
()
{
var
name
=
"{{ cluster.name }}"
;
...
...
apps/assets/templates/assets/system_user_asset.html
View file @
0848893f
...
...
@@ -125,7 +125,7 @@ function initAssetsTable() {
}
$
(
document
).
ready
(
function
()
{
$
(
'.select2'
).
select2
(
)
$
(
'.select2'
).
select2
(
{
dropdownAutoWidth
:
true
,
width
:
'auto'
});
.
on
(
"select2:select"
,
function
(
evt
)
{
var
data
=
evt
.
params
.
data
;
jumpserver
.
assets_selected
[
data
.
id
]
=
data
.
text
;
...
...
apps/assets/templates/assets/system_user_detail.html
View file @
0848893f
...
...
@@ -212,7 +212,7 @@ function updateSystemUserCluster(clusters) {
}
jumpserver
.
cluster_selected
=
{};
$
(
document
).
ready
(
function
()
{
$
(
'.select2'
).
select2
(
)
$
(
'.select2'
).
select2
(
{
dropdownAutoWidth
:
true
,
width
:
'auto'
});
.
on
(
'select2:select'
,
function
(
evt
)
{
var
data
=
evt
.
params
.
data
;
jumpserver
.
cluster_selected
[
data
.
id
]
=
data
.
text
;
...
...
apps/assets/templates/assets/system_user_update.html
View file @
0848893f
...
...
@@ -18,7 +18,7 @@
{% block custom_foot_js %}
<script>
$
(
document
).
ready
(
function
()
{
$
(
'.select2'
).
select2
();
$
(
'.select2'
).
select2
(
{
dropdownAutoWidth
:
true
,
width
:
'auto'
}
);
})
</script>
{% endblock %}
\ No newline at end of file
apps/common/mixins.py
View file @
0848893f
...
...
@@ -3,14 +3,14 @@
import
inspect
from
django.db
import
models
from
django.http
import
JsonResponse
from
django.utils
.timezone
import
now
from
django.utils
import
timezone
from
django.utils.translation
import
ugettext_lazy
as
_
class
NoDeleteQuerySet
(
models
.
query
.
QuerySet
):
def
delete
(
self
):
return
self
.
update
(
is_discard
=
True
,
discard_time
=
now
())
return
self
.
update
(
is_discard
=
True
,
discard_time
=
timezone
.
now
())
class
NoDeleteManager
(
models
.
Manager
):
...
...
@@ -36,7 +36,7 @@ class NoDeleteModelMixin(models.Model):
def
delete
(
self
):
self
.
is_discard
=
True
self
.
discard_time
=
now
()
self
.
discard_time
=
timezone
.
now
()
return
self
.
save
()
...
...
@@ -87,3 +87,29 @@ class BulkSerializerMixin(object):
return
ret
class
DatetimeSearchMixin
:
date_from
=
date_to
=
None
def
get
(
self
,
request
,
*
args
,
**
kwargs
):
date_from_s
=
self
.
request
.
GET
.
get
(
'date_from'
)
date_to_s
=
self
.
request
.
GET
.
get
(
'date_to'
)
if
date_from_s
:
date_from
=
timezone
.
datetime
.
strptime
(
date_from_s
,
'
%
m/
%
d/
%
Y'
)
self
.
date_from
=
date_from
.
replace
(
tzinfo
=
timezone
.
get_current_timezone
()
)
else
:
self
.
date_from
=
timezone
.
now
()
-
timezone
.
timedelta
(
7
)
if
date_to_s
:
date_to
=
timezone
.
datetime
.
strptime
(
date_to_s
+
' 23:59:59'
,
'
%
m/
%
d/
%
Y
%
H:
%
M:
%
S'
)
self
.
date_to
=
date_to
.
replace
(
tzinfo
=
timezone
.
get_current_timezone
()
)
else
:
self
.
date_to
=
timezone
.
now
()
return
super
()
.
get
(
request
,
*
args
,
**
kwargs
)
\ No newline at end of file
apps/ops/templates/ops/task_list.html
View file @
0848893f
...
...
@@ -16,9 +16,9 @@
<div
class=
"form-group"
id=
"date"
>
<div
class=
"input-daterange input-group"
id=
"datepicker"
>
<span
class=
"input-group-addon"
><i
class=
"fa fa-calendar"
></i></span>
<input
type=
"text"
class=
"input-sm form-control"
style=
"width: 100px;"
name=
"date_from"
value=
"{{ date_from }}"
>
<input
type=
"text"
class=
"input-sm form-control"
style=
"width: 100px;"
name=
"date_from"
value=
"{{ date_from
|date:"
m
/
d
/
Y
"
}}"
>
<span
class=
"input-group-addon"
>
to
</span>
<input
type=
"text"
class=
"input-sm form-control"
style=
"width: 100px;"
name=
"date_to"
value=
"{{ date_to }}"
>
<input
type=
"text"
class=
"input-sm form-control"
style=
"width: 100px;"
name=
"date_to"
value=
"{{ date_to
|date:"
m
/
d
/
Y
"
}}"
>
</div>
</div>
<div
class=
"input-group"
>
...
...
@@ -89,7 +89,10 @@ $(document).ready(function() {
"bInfo"
:
false
,
"order"
:
[]
});
$
(
'.select2'
).
select2
();
$
(
'.select2'
).
select2
({
dropdownAutoWidth
:
true
,
width
:
'auto'
});
$
(
'#date .input-daterange'
).
datepicker
({
dateFormat
:
'mm/dd/yy'
,
keyboardNavigation
:
false
,
...
...
apps/ops/views.py
View file @
0848893f
...
...
@@ -9,40 +9,27 @@ from django.views.generic import ListView, DetailView, View
from
django.utils
import
timezone
from
django.shortcuts
import
redirect
,
reverse
from
common.mixins
import
DatetimeSearchMixin
from
.models
import
Task
,
AdHoc
,
AdHocRunHistory
from
ops.tasks
import
rerun_task
class
TaskListView
(
ListView
):
class
TaskListView
(
DatetimeSearchMixin
,
ListView
):
paginate_by
=
settings
.
CONFIG
.
DISPLAY_PER_PAGE
model
=
Task
ordering
=
(
'-date_created'
,)
context_object_name
=
'task_list'
template_name
=
'ops/task_list.html'
date_format
=
'
%
m/
%
d/
%
Y'
keyword
=
date_from_s
=
date_to_s
=
''
keyword
=
''
def
get_queryset
(
self
):
date_to_default
=
timezone
.
now
()
date_from_default
=
timezone
.
now
()
-
timezone
.
timedelta
(
7
)
date_from_default_s
=
date_from_default
.
strftime
(
self
.
date_format
)
date_to_default_s
=
date_to_default
.
strftime
(
self
.
date_format
)
self
.
queryset
=
super
()
.
get_queryset
()
self
.
keyword
=
self
.
request
.
GET
.
get
(
'keyword'
,
''
)
self
.
date_from_s
=
self
.
request
.
GET
.
get
(
'date_from'
,
date_from_default_s
)
self
.
date_to_s
=
self
.
request
.
GET
.
get
(
'date_to'
,
date_to_default_s
)
if
self
.
date_from_s
:
date_from
=
datetime
.
strptime
(
self
.
date_from_s
,
self
.
date_format
)
date_from
=
date_from
.
replace
(
tzinfo
=
timezone
.
get_current_timezone
())
self
.
queryset
=
self
.
queryset
.
filter
(
date_created__gt
=
date_from
)
if
self
.
date_to_s
:
date_to
=
timezone
.
datetime
.
strptime
(
self
.
date_to_s
+
' 23:59:59'
,
'
%
m/
%
d/
%
Y
%
H:
%
M:
%
S'
)
date_to
=
date_to
.
replace
(
tzinfo
=
timezone
.
get_current_timezone
())
self
.
queryset
=
self
.
queryset
.
filter
(
date_created__lt
=
date_to
)
self
.
queryset
=
self
.
queryset
.
filter
(
date_created__gt
=
self
.
date_from
,
date_created__lt
=
self
.
date_to
)
if
self
.
keyword
:
self
.
queryset
=
self
.
queryset
.
filter
(
...
...
@@ -51,15 +38,16 @@ class TaskListView(ListView):
return
self
.
queryset
def
get_context_data
(
self
,
**
kwargs
):
print
(
self
.
date_from
)
context
=
{
'app'
:
'Ops'
,
'action'
:
_
(
'Task list'
),
'date_from'
:
self
.
date_from
_s
,
'date_to'
:
self
.
date_to
_s
,
'date_from'
:
self
.
date_from
,
'date_to'
:
self
.
date_to
,
'keyword'
:
self
.
keyword
,
}
kwargs
.
update
(
context
)
return
super
(
TaskListView
,
self
)
.
get_context_data
(
**
kwargs
)
return
super
()
.
get_context_data
(
**
kwargs
)
class
TaskDetailView
(
DetailView
):
...
...
apps/perms/templates/perms/asset_permission_create_update.html
View file @
0848893f
...
...
@@ -79,7 +79,7 @@
<script
src=
"{% static 'js/plugins/datepicker/bootstrap-datepicker.js' %}"
></script>
<script>
$
(
document
).
ready
(
function
()
{
$
(
'.select2'
).
select2
();
$
(
'.select2'
).
select2
(
{
dropdownAutoWidth
:
true
,
width
:
'auto'
}
);
$
(
'.input-group.date'
).
datepicker
({
format
:
"yyyy-mm-dd"
,
...
...
apps/perms/templates/perms/asset_permission_detail.html
View file @
0848893f
...
...
@@ -190,7 +190,7 @@ function updateSystemUser(system_users) {
}
$
(
document
).
ready
(
function
()
{
$
(
'.select2'
).
select2
(
)
$
(
'.select2'
).
select2
(
{
dropdownAutoWidth
:
true
,
width
:
'auto'
});
.
on
(
'select2:select'
,
function
(
evt
)
{
var
data
=
evt
.
params
.
data
;
jumpserver
.
system_users_selected
[
data
.
id
]
=
data
.
text
;
...
...
apps/terminal/templates/terminal/command_list.html
View file @
0848893f
...
...
@@ -5,6 +5,8 @@
{% block custom_head_css_js %}
<link
href=
"{% static "
css
/
plugins
/
footable
/
footable
.
core
.
css
"
%}"
rel=
"stylesheet"
>
<link
href=
"{% static 'css/plugins/datepicker/datepicker3.css' %}"
rel=
"stylesheet"
>
<link
href=
"{% static 'css/plugins/select2/select2.min.css' %}"
rel=
"stylesheet"
>
<script
src=
"{% static 'js/plugins/select2/select2.full.min.js' %}"
></script>
<style>
#search_btn
{
margin-bottom
:
0
;
...
...
@@ -20,9 +22,9 @@
<div
class=
"form-group"
id=
"date"
>
<div
class=
"input-daterange input-group"
id=
"datepicker"
>
<span
class=
"input-group-addon"
><i
class=
"fa fa-calendar"
></i></span>
<input
type=
"text"
class=
"input-sm form-control"
style=
"width: 100px;"
name=
"date_from"
value=
"{{ date_from }}"
>
<input
type=
"text"
class=
"input-sm form-control"
style=
"width: 100px;"
name=
"date_from"
value=
"{{ date_from
|date:"
m
/
d
/
Y
"
}}"
>
<span
class=
"input-group-addon"
>
to
</span>
<input
type=
"text"
class=
"input-sm form-control"
style=
"width: 100px;"
name=
"date_to"
value=
"{{ date_to }}"
>
<input
type=
"text"
class=
"input-sm form-control"
style=
"width: 100px;"
name=
"date_to"
value=
"{{ date_to
|date:"
m
/
d
/
Y
"
}}"
>
</div>
</div>
<div
class=
"input-group"
>
...
...
@@ -93,20 +95,23 @@
{% endblock %}
{% block custom_foot_js %}
<script
src=
"{% static "
js
/
plugins
/
footable
/
footable
.
all
.
min
.
js
"
%}"
></script>
<script
src=
"{% static 'js/plugins/datepicker/bootstrap-datepicker.js' %}"
></script>
<script>
$
(
document
).
ready
(
function
()
{
$
(
'.footable'
).
footable
();
$
(
'.select2'
).
select2
();
$
(
'#date .input-daterange'
).
datepicker
({
dateFormat
:
'mm/dd/yy'
,
keyboardNavigation
:
false
,
forceParse
:
false
,
autoclose
:
true
});
<script
src=
"{% static "
js
/
plugins
/
footable
/
footable
.
all
.
min
.
js
"
%}"
></script>
<script
src=
"{% static 'js/plugins/datepicker/bootstrap-datepicker.js' %}"
></script>
<script>
$
(
document
).
ready
(
function
()
{
$
(
'.footable'
).
footable
();
$
(
'.select2'
).
select2
({
dropdownAutoWidth
:
true
,
width
:
'auto'
});
</script>
$
(
'#date .input-daterange'
).
datepicker
({
dateFormat
:
'mm/dd/yy'
,
keyboardNavigation
:
false
,
forceParse
:
false
,
autoclose
:
true
});
});
</script>
{% endblock %}
apps/terminal/templates/terminal/session_list.html
View file @
0848893f
...
...
@@ -4,6 +4,8 @@
{% load terminal_tags %}
{% block custom_head_css_js %}
<link
href=
"{% static 'css/plugins/datepicker/datepicker3.css' %}"
rel=
"stylesheet"
>
<link
href=
"{% static "
css
/
plugins
/
select2
/
select2
.
min
.
css
"
%}"
rel=
"stylesheet"
>
<script
src=
"{% static "
js
/
plugins
/
select2
/
select2
.
full
.
min
.
js
"
%}"
></script>
<style>
#search_btn
{
margin-bottom
:
0
;
...
...
@@ -20,9 +22,9 @@
<div
class=
"form-group"
id=
"date"
>
<div
class=
"input-daterange input-group"
id=
"datepicker"
>
<span
class=
"input-group-addon"
><i
class=
"fa fa-calendar"
></i></span>
<input
type=
"text"
class=
"input-sm form-control"
style=
"width: 100px;"
name=
"date_from"
value=
"{{ date_from }}"
>
<input
type=
"text"
class=
"input-sm form-control"
style=
"width: 100px;"
name=
"date_from"
value=
"{{ date_from
|date:"
m
/
d
/
Y
"
}}"
>
<span
class=
"input-group-addon"
>
to
</span>
<input
type=
"text"
class=
"input-sm form-control"
style=
"width: 100px;"
name=
"date_to"
value=
"{{ date_to }}"
>
<input
type=
"text"
class=
"input-sm form-control"
style=
"width: 100px;"
name=
"date_to"
value=
"{{ date_to
|date:"
m
/
d
/
Y
"
}}"
>
</div>
</div>
<div
class=
"input-group"
>
...
...
@@ -129,7 +131,8 @@
"order"
:
[]
});
$
(
'.select2'
).
select2
({
dropdownAutoWidth
:
true
dropdownAutoWidth
:
true
,
width
:
"auto"
});
$
(
'#date .input-daterange'
).
datepicker
({
dateFormat
:
'mm/dd/yy'
,
...
...
apps/terminal/templates/terminal/terminal_update.html
View file @
0848893f
...
...
@@ -57,7 +57,7 @@
<script
src=
"{% static 'js/plugins/datepicker/bootstrap-datepicker.js' %}"
></script>
<script>
$
(
document
).
ready
(
function
()
{
$
(
'.select2'
).
select2
();
$
(
'.select2'
).
select2
(
{
dropdownAutoWidth
:
true
,
width
:
'auto'
}
);
$
(
'.input-group.date'
).
datepicker
({
format
:
"yyyy-mm-dd"
,
...
...
apps/terminal/views/command.py
View file @
0848893f
# -*- coding: utf-8 -*-
#
from
datetime
import
datetime
from
django.views.generic
import
ListView
from
django.conf
import
settings
from
django.utils
import
timezone
from
django.utils.translation
import
ugettext
as
_
from
common.mixins
import
DatetimeSearchMixin
from
..models
import
Command
from
..
import
utils
from
..backends
import
get_command_store
...
...
@@ -15,39 +15,19 @@ __all__ = ['CommandListView']
command_store
=
get_command_store
()
class
CommandListView
(
ListView
):
class
CommandListView
(
DatetimeSearchMixin
,
ListView
):
model
=
Command
template_name
=
"terminal/command_list.html"
context_object_name
=
'command_list'
paginate_by
=
settings
.
CONFIG
.
DISPLAY_PER_PAGE
command
=
user
=
asset
=
system_user
=
date_from_s
=
date_to_s
=
''
command
=
user
=
asset
=
system_user
=
""
date_from
=
date_to
=
None
date_format
=
'
%
m/
%
d/
%
Y'
def
get_queryset
(
self
):
date_to_default
=
timezone
.
now
()
date_from_default
=
timezone
.
now
()
-
timezone
.
timedelta
(
7
)
date_to_default_s
=
date_to_default
.
strftime
(
self
.
date_format
)
date_from_default_s
=
date_from_default
.
strftime
(
self
.
date_format
)
self
.
command
=
self
.
request
.
GET
.
get
(
'command'
,
''
)
self
.
user
=
self
.
request
.
GET
.
get
(
'user'
)
self
.
asset
=
self
.
request
.
GET
.
get
(
'asset'
)
self
.
system_user
=
self
.
request
.
GET
.
get
(
'system_user'
)
self
.
date_from_s
=
self
.
request
.
GET
.
get
(
'date_from'
,
date_from_default_s
)
self
.
date_to_s
=
self
.
request
.
GET
.
get
(
'date_to'
,
date_to_default_s
)
filter_kwargs
=
{}
if
self
.
date_from_s
:
date_from
=
datetime
.
strptime
(
self
.
date_from_s
,
self
.
date_format
)
date_from
=
date_from
.
replace
(
tzinfo
=
timezone
.
get_current_timezone
()
)
filter_kwargs
[
'date_from'
]
=
date_from
if
self
.
date_to_s
:
date_to
=
timezone
.
datetime
.
strptime
(
self
.
date_to_s
+
' 23:59:59'
,
'
%
m/
%
d/
%
Y
%
H:
%
M:
%
S'
)
date_to
=
date_to
.
replace
(
tzinfo
=
timezone
.
get_current_timezone
())
filter_kwargs
[
'date_to'
]
=
date_to
filter_kwargs
=
dict
()
filter_kwargs
[
'date_from'
]
=
self
.
date_from
filter_kwargs
[
'date_to'
]
=
self
.
date_to
if
self
.
user
:
filter_kwargs
[
'user'
]
=
self
.
user
if
self
.
asset
:
...
...
@@ -68,8 +48,8 @@ class CommandListView(ListView):
'asset_list'
:
utils
.
get_asset_list_from_cache
(),
'system_user_list'
:
utils
.
get_system_user_list_from_cache
(),
'command'
:
self
.
command
,
'date_from'
:
self
.
date_from
_s
,
'date_to'
:
self
.
date_to
_s
,
'date_from'
:
self
.
date_from
,
'date_to'
:
self
.
date_to
,
'username'
:
self
.
user
,
'asset'
:
self
.
asset
,
'system_user'
:
self
.
system_user
,
...
...
apps/terminal/views/session.py
View file @
0848893f
# -*- coding: utf-8 -*-
#
import
time
from
datetime
import
datetime
from
django.views.generic
import
ListView
,
UpdateView
,
DeleteView
,
DetailView
,
TemplateView
from
django.views.generic.edit
import
SingleObjectMixin
from
django.utils.translation
import
ugettext
as
_
from
django.utils
import
timezone
from
django.utils.module_loading
import
import_string
from
django.urls
import
reverse_lazy
from
django.http
import
HttpResponse
from
django.conf
import
settings
from
django.db.models
import
Q
from
users.utils
import
AdminUserRequiredMixin
from
common.mixins
import
DatetimeSearchMixin
from
..models
import
Session
,
Command
,
Terminal
from
..backends
import
get_command_store
from
..
import
utils
...
...
@@ -28,37 +22,24 @@ __all__ = [
command_store
=
get_command_store
()
class
SessionListView
(
AdminUserRequiredMixin
,
ListView
):
class
SessionListView
(
AdminUserRequiredMixin
,
DatetimeSearchMixin
,
ListView
):
model
=
Session
template_name
=
'terminal/session_list.html'
context_object_name
=
'session_list'
paginate_by
=
settings
.
CONFIG
.
DISPLAY_PER_PAGE
user
=
asset
=
system_user
=
date_from_s
=
date_to_s
=
''
user
=
asset
=
system_user
=
''
date_from
=
date_to
=
None
date_format
=
'
%
m/
%
d/
%
Y'
def
get_queryset
(
self
):
date_to_default
=
timezone
.
now
()
date_from_default
=
timezone
.
now
()
-
timezone
.
timedelta
(
7
)
date_to_default_s
=
date_to_default
.
strftime
(
self
.
date_format
)
date_from_default_s
=
date_from_default
.
strftime
(
self
.
date_format
)
self
.
queryset
=
super
()
.
get_queryset
()
self
.
user
=
self
.
request
.
GET
.
get
(
'user'
)
self
.
asset
=
self
.
request
.
GET
.
get
(
'asset'
)
self
.
system_user
=
self
.
request
.
GET
.
get
(
'system_user'
)
self
.
date_from_s
=
self
.
request
.
GET
.
get
(
'date_from'
,
date_from_default_s
)
self
.
date_to_s
=
self
.
request
.
GET
.
get
(
'date_to'
,
date_to_default_s
)
filter_kwargs
=
{}
if
self
.
date_from_s
:
date_from
=
datetime
.
strptime
(
self
.
date_from_s
,
self
.
date_format
)
date_from
=
date_from
.
replace
(
tzinfo
=
timezone
.
get_current_timezone
())
filter_kwargs
[
'date_start__gt'
]
=
date_from
if
self
.
date_to_s
:
date_to
=
timezone
.
datetime
.
strptime
(
self
.
date_to_s
+
' 23:59:59'
,
'
%
m/
%
d/
%
Y
%
H:
%
M:
%
S'
)
date_to
=
date_to
.
replace
(
tzinfo
=
timezone
.
get_current_timezone
())
filter_kwargs
[
'date_start__lt'
]
=
date_to
filter_kwargs
=
dict
()
filter_kwargs
[
'date_start__gt'
]
=
self
.
date_from
filter_kwargs
[
'date_start__lt'
]
=
self
.
date_to
if
self
.
user
:
filter_kwargs
[
'user'
]
=
self
.
user
if
self
.
asset
:
...
...
@@ -76,8 +57,8 @@ class SessionListView(AdminUserRequiredMixin, ListView):
'user_list'
:
utils
.
get_user_list_from_cache
(),
'asset_list'
:
utils
.
get_asset_list_from_cache
(),
'system_user_list'
:
utils
.
get_system_user_list_from_cache
(),
'date_from'
:
self
.
date_from
_s
,
'date_to'
:
self
.
date_to
_s
,
'date_from'
:
self
.
date_from
,
'date_to'
:
self
.
date_to
,
'username'
:
self
.
user
,
'asset'
:
self
.
asset
,
'system_user'
:
self
.
system_user
,
...
...
apps/users/templates/users/_user.html
View file @
0848893f
...
...
@@ -56,7 +56,7 @@
<script
src=
"{% static 'js/plugins/datepicker/bootstrap-datepicker.js' %}"
></script>
<script>
$
(
document
).
ready
(
function
()
{
$
(
'.select2'
).
select2
();
$
(
'.select2'
).
select2
(
{
dropdownAutoWidth
:
true
,
width
:
'auto'
}
);
$
(
'.input-group.date'
).
datepicker
({
format
:
"yyyy-mm-dd"
,
...
...
apps/users/templates/users/login_log_list.html
View file @
0848893f
...
...
@@ -17,9 +17,10 @@
<div
class=
"form-group"
id=
"date"
>
<div
class=
"input-daterange input-group"
id=
"datepicker"
>
<span
class=
"input-group-addon"
><i
class=
"fa fa-calendar"
></i></span>
<input
type=
"text"
class=
"input-sm form-control"
style=
"width: 100px;"
name=
"date_from"
value=
"{{ date_from }}"
>
<input
type=
"text"
class=
"input-sm form-control"
style=
"width: 100px;"
name=
"date_from"
value=
"{{ date_from|date:"
m
/
d
/
Y
"}}"
>
{#
<input
type=
"text"
class=
"input-sm form-control"
style=
"width: 100px;"
name=
"date_from"
>
#}
<span
class=
"input-group-addon"
>
to
</span>
<input
type=
"text"
class=
"input-sm form-control"
style=
"width: 100px;"
name=
"date_to"
value=
"{{ date_to
}}"
>
<input
type=
"text"
class=
"input-sm form-control"
style=
"width: 100px;"
name=
"date_to"
value=
"{{ date_to
|date:"
m
/
d
/
Y
"
}}"
>
</div>
</div>
<div
class=
"input-group"
>
...
...
@@ -80,10 +81,11 @@
"order"
:
[]
});
$
(
'#date .input-daterange'
).
datepicker
({
dateFormat
:
'mm/dd/yy'
,
dateFormat
:
"mm/dd/yyy"
,
keyboardNavigation
:
false
,
forceParse
:
false
,
autoclose
:
true
});
$
(
'.select2'
).
select2
({
dropdownAutoWidth
:
true
...
...
apps/users/templates/users/user_bulk_update.html
View file @
0848893f
...
...
@@ -30,7 +30,7 @@
{% block custom_foot_js %}
<script>
$
(
document
).
ready
(
function
()
{
$
(
'.select2'
).
select2
();
$
(
'.select2'
).
select2
(
{
dropdownAutoWidth
:
true
,
width
:
'auto'
}
);
}).
on
(
'click'
,
'.field-tag'
,
function
()
{
changeField
(
this
);
}).
on
(
'click'
,
'#change_all'
,
function
()
{
...
...
apps/users/templates/users/user_detail.html
View file @
0848893f
...
...
@@ -253,7 +253,7 @@ function updateUserGroups(groups) {
}
$
(
document
).
ready
(
function
()
{
$
(
'.select2'
).
select2
(
)
$
(
'.select2'
).
select2
(
{
dropdownAutoWidth
:
true
,
width
:
'auto'
});
.
on
(
'select2:select'
,
function
(
evt
)
{
var
data
=
evt
.
params
.
data
;
jumpserver
.
groups_selected
[
data
.
id
]
=
data
.
text
;
...
...
apps/users/templates/users/user_granted_asset.html
View file @
0848893f
...
...
@@ -98,7 +98,7 @@
{% block custom_foot_js %}
<script>
$
(
document
).
ready
(
function
()
{
$
(
'.select2'
).
select2
();
$
(
'.select2'
).
select2
(
{
dropdownAutoWidth
:
true
,
width
:
'auto'
}
);
var
options
=
{
ele
:
$
(
'#user_assets_table'
),
buttons
:
[],
...
...
apps/users/templates/users/user_group_create_update.html
View file @
0848893f
...
...
@@ -57,7 +57,7 @@
{% block custom_foot_js %}
<script>
$
(
document
).
ready
(
function
()
{
$
(
'.select2'
).
select2
();
$
(
'.select2'
).
select2
(
{
dropdownAutoWidth
:
true
,
width
:
'auto'
}
);
})
</script>
{% endblock %}
apps/users/templates/users/user_group_detail.html
View file @
0848893f
...
...
@@ -150,7 +150,7 @@ function updateGroupMember(users) {
}
$
(
document
).
ready
(
function
()
{
$
(
'.select2'
).
select2
(
)
$
(
'.select2'
).
select2
(
{
dropdownAutoWidth
:
true
,
width
:
'auto'
});
.
on
(
'select2:select'
,
function
(
evt
)
{
var
data
=
evt
.
params
.
data
;
jumpserver
.
users_selected
[
data
.
id
]
=
data
.
text
;
...
...
apps/users/templates/users/user_group_granted_asset.html
View file @
0848893f
...
...
@@ -102,7 +102,7 @@
{% block custom_foot_js %}
<script>
$
(
document
).
ready
(
function
()
{
$
(
'.select2'
).
select2
();
$
(
'.select2'
).
select2
(
{
dropdownAutoWidth
:
true
,
width
:
'auto'
}
);
var
options
=
{
ele
:
$
(
'#user_assets_table'
),
buttons
:
[],
...
...
apps/users/views/login.py
View file @
0848893f
...
...
@@ -22,6 +22,7 @@ from django.conf import settings
from
django.utils
import
timezone
from
common.utils
import
get_object_or_none
from
common.mixins
import
DatetimeSearchMixin
from
..models
import
User
,
LoginLog
from
..utils
import
send_reset_password_mail
from
..tasks
import
write_login_log_async
...
...
@@ -210,55 +211,38 @@ class UserFirstLoginView(LoginRequiredMixin, SessionWizardView):
return
form
class
LoginLogListView
(
ListView
):
class
LoginLogListView
(
DatetimeSearchMixin
,
ListView
):
template_name
=
'users/login_log_list.html'
model
=
LoginLog
paginate_by
=
settings
.
CONFIG
.
DISPLAY_PER_PAGE
username
=
keyword
=
date_from_s
=
date_to_s
=
""
username
=
keyword
=
""
date_to
=
date_from
=
None
date_format
=
'
%
m/
%
d/
%
Y'
def
get_queryset
(
self
):
date_to_default
=
timezone
.
now
()
date_from_default
=
timezone
.
now
()
-
timezone
.
timedelta
(
7
)
date_to_default_s
=
date_to_default
.
strftime
(
self
.
date_format
)
date_from_default_s
=
date_from_default
.
strftime
(
self
.
date_format
)
self
.
username
=
self
.
request
.
GET
.
get
(
'username'
,
''
)
self
.
keyword
=
self
.
request
.
GET
.
get
(
"keyword"
,
''
)
self
.
date_from_s
=
self
.
request
.
GET
.
get
(
'date_from'
,
date_from_default_s
)
self
.
date_to_s
=
self
.
request
.
GET
.
get
(
'date_to'
,
date_to_default_s
)
self
.
queryset
=
super
()
.
get_queryset
()
queryset
=
super
()
.
get_queryset
()
queryset
=
queryset
.
filter
(
datetime__gt
=
self
.
date_from
,
datetime__lt
=
self
.
date_to
)
if
self
.
username
:
self
.
queryset
=
self
.
queryset
.
filter
(
username
=
self
.
username
)
if
self
.
date_from_s
:
date_from
=
timezone
.
datetime
.
strptime
(
self
.
date_from_s
,
'
%
m/
%
d/
%
Y'
)
date_from
=
date_from
.
replace
(
tzinfo
=
timezone
.
get_current_timezone
()
)
self
.
queryset
=
self
.
queryset
.
filter
(
datetime__gt
=
date_from
)
if
self
.
date_to_s
:
date_to
=
timezone
.
datetime
.
strptime
(
self
.
date_to_s
+
' 23:59:59'
,
'
%
m/
%
d/
%
Y
%
H:
%
M:
%
S'
)
date_to
=
date_to
.
replace
(
tzinfo
=
timezone
.
get_current_timezone
()
)
self
.
queryset
=
self
.
queryset
.
filter
(
datetime__lt
=
date_to
)
queryset
=
self
.
queryset
.
filter
(
username
=
self
.
username
)
if
self
.
keyword
:
self
.
queryset
=
self
.
queryset
.
filter
(
queryset
=
self
.
queryset
.
filter
(
Q
(
ip__contains
=
self
.
keyword
)
|
Q
(
city__contains
=
self
.
keyword
)
|
Q
(
username__contains
=
self
.
keyword
)
)
return
self
.
queryset
return
queryset
def
get_context_data
(
self
,
**
kwargs
):
context
=
{
'app'
:
_
(
'Users'
),
'action'
:
_
(
'Login log list'
),
'date_from'
:
self
.
date_from
_s
,
'date_to'
:
self
.
date_to
_s
,
'date_from'
:
self
.
date_from
,
'date_to'
:
self
.
date_to
,
'username'
:
self
.
username
,
'keyword'
:
self
.
keyword
,
'user_list'
:
set
(
LoginLog
.
objects
.
all
()
.
values_list
(
'username'
,
flat
=
True
))
...
...
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