Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
gjl2004yn
jumpserver
提交
d56f030d
J
jumpserver
项目概览
gjl2004yn
/
jumpserver
与 Fork 源项目一致
从无法访问的项目Fork
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
J
jumpserver
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
d56f030d
编写于
12月 27, 2016
作者:
baltery
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Finish terminal accept
上级
775cd523
变更
10
隐藏空白更改
内联
并排
Showing
10 changed file
with
131 addition
and
14 deletion
+131
-14
apps/applications/forms.py
apps/applications/forms.py
+3
-1
apps/applications/models.py
apps/applications/models.py
+2
-2
apps/applications/templates/applications/terminal_form.html
apps/applications/templates/applications/terminal_form.html
+0
-0
apps/applications/templates/applications/terminal_list.html
apps/applications/templates/applications/terminal_list.html
+41
-2
apps/applications/templates/applications/terminal_modal_accept.bak.html
...ons/templates/applications/terminal_modal_accept.bak.html
+26
-0
apps/applications/templates/applications/terminal_modal_accept.html
...cations/templates/applications/terminal_modal_accept.html
+18
-0
apps/applications/urls/views_urls.py
apps/applications/urls/views_urls.py
+1
-0
apps/applications/views.py
apps/applications/views.py
+36
-3
apps/templates/base.html
apps/templates/base.html
+1
-0
apps/users/templates/users/user_list.html
apps/users/templates/users/user_list.html
+3
-6
未找到文件。
apps/applications/forms.py
浏览文件 @
d56f030d
...
...
@@ -14,4 +14,6 @@ class TerminalForm(forms.ModelForm):
help_texts
=
{
'url'
:
'Example: ssh://192.168.1.1:22 or http://jms.jumpserver.org, that user login'
}
widgets
=
{
'name'
:
forms
.
TextInput
(
attrs
=
{
'readonly'
:
'readonly'
})
}
\ No newline at end of file
apps/applications/models.py
浏览文件 @
d56f030d
...
...
@@ -13,7 +13,7 @@ class Terminal(models.Model):
)
name
=
models
.
CharField
(
max_length
=
30
,
unique
=
True
,
verbose_name
=
_
(
'Name'
))
remote_addr
=
models
.
GenericIPAddressField
(
verbose_name
=
_
(
'Remote address'
),
blank
=
True
,
null
=
True
)
type
=
models
.
CharField
(
choices
=
TYPE_CHOICES
,
max_length
=
2
,
blank
=
True
,
verbose_name
=
_
(
'Terminal type'
))
type
=
models
.
CharField
(
choices
=
TYPE_CHOICES
,
max_length
=
3
,
blank
=
True
,
verbose_name
=
_
(
'Terminal type'
))
user
=
models
.
OneToOneField
(
User
,
verbose_name
=
'Application user'
,
null
=
True
)
url
=
models
.
CharField
(
max_length
=
100
,
blank
=
True
,
verbose_name
=
_
(
'URL to login'
))
is_accepted
=
models
.
BooleanField
(
default
=
False
,
verbose_name
=
'Is Accepted'
)
...
...
@@ -53,7 +53,7 @@ class Terminal(models.Model):
__str__
=
__unicode__
class
Meta
:
db_table
=
'applications'
ordering
=
(
'is_accepted'
,)
class
TerminalHeatbeat
(
models
.
Model
):
...
...
apps/applications/templates/applications/terminal_form.html
0 → 100644
浏览文件 @
d56f030d
apps/applications/templates/applications/terminal_list.html
浏览文件 @
d56f030d
...
...
@@ -2,15 +2,17 @@
{% load i18n static %}
{% block custom_head_css_js %}
{{ block.super }}
<style>
div
.dataTables_wrapper
div
.dataTables_filter
,
.dataTables_length
{
float
:
right
!important
;
}
div
.dataTables_wrapper
div
.dataTables_filter
{
margin-left
:
15px
;
}
#modal
.modal-body
{
max-height
:
200px
;
}
</style>
{% endblock %}
{% block table_search %}{% endblock %}
...
...
@@ -36,6 +38,8 @@
<tbody>
</tbody>
</table>
{% include 'applications/terminal_modal_accept.html' %}
{% endblock %}
{% block custom_foot_js %}
<script
src=
"{% static 'js/jquery.form.min.js' %}"
></script>
...
...
@@ -70,7 +74,7 @@ $(document).ready(function(){
var
delete_btn
=
'
<a class="btn btn-xs btn-danger m-l-xs btn_delete" data-uid="99991937" data-name="99991938">{% trans "Delete" %}</a>
'
.
replace
(
'
99991937
'
,
cellData
)
.
replace
(
'
99991938
'
,
rowData
.
name
);
var
accept_btn
=
'
<a
href="" class="btn btn-xs btn-primary
">{% trans "Accept" %}</a>
'
var
accept_btn
=
'
<a
class="btn btn-xs btn-primary btn-accept" data-id="99991937
">{% trans "Accept" %}</a>
'
.
replace
(
'
99991937
'
,
cellData
);
var
reject_btn
=
'
<a href="" class="btn btn-xs btn-danger">{% trans "Reject" %}</a>
'
if
(
rowData
.
is_accepted
)
{
...
...
@@ -86,12 +90,47 @@ $(document).ready(function(){
op_html
:
$
(
'
#actions
'
).
html
()
};
jumpserver
.
initDataTable
(
options
);
}).
on
(
'
click
'
,
'
.btn_delete
'
,
function
(){
var
$this
=
$
(
this
);
var
uid
=
$this
.
data
(
'
uid
'
);
var
name
=
$
(
this
).
data
(
'
name
'
);
var
the_url
=
'
{% url "api-applications:terminal-detail" pk=99991937 %}
'
.
replace
(
'
99991937
'
,
uid
);
objectDelete
(
$this
,
name
,
the_url
)
}).
on
(
'
click
'
,
'
.btn-accept
'
,
function
()
{
var
$this
=
$
(
this
);
var
terminal_id
=
$this
.
data
(
'
id
'
);
var
the_url
=
"
{% url 'api-applications:terminal-detail' pk=99991937 %}
"
.
replace
(
'
99991937
'
,
terminal_id
);
var
post_url
=
$
(
'
#form_terminal_accept
'
).
attr
(
'
action
'
).
replace
(
'
99991937
'
,
terminal_id
);
console
.
log
(
post_url
);
$
.
ajax
({
url
:
the_url
,
method
:
'
GET
'
,
success
:
function
(
data
)
{
$
(
'
#id_name
'
).
val
(
data
.
name
);
$
(
'
#id_remote_addr
'
).
val
(
data
.
remote_addr
);
$
(
'
#id_type
'
).
val
(
data
.
type
);
$
(
'
#id_url
'
).
val
(
data
.
url
);
$
(
'
#id_comment
'
).
val
(
data
.
comment
);
$
(
'
#form_terminal_accept
'
).
attr
(
'
action
'
,
post_url
)
}
});
$
(
'
#modal_terminal_accept
'
).
modal
({
show
:
true
});
}).
on
(
'
click
'
,
'
#btn_terminal_accept
'
,
function
()
{
var
$form
=
$
(
'
#form_terminal_accept
'
);
function
success
(
data
,
textStatus
,
jqXHR
)
{
if
(
data
.
success
===
false
)
{
console
.
log
(
data
.
msg
);
window
.
location
.
reload
()
}
else
{
console
.
log
(
data
.
msg
);
}
}
$form
.
ajaxSubmit
({
success
:
success
});
})
</script>
{% endblock %}
apps/applications/templates/applications/terminal_modal_accept.bak.html
0 → 100644
浏览文件 @
d56f030d
{% extends '_modal.html' %}
{% load static %}
{% load bootstrap %}
{% load i18n %}
{% block modal_body %}
<form
action=
""
method=
"post"
class=
"form-horizontal"
>
{% csrf_token %}
{{ form.name|bootstrap_horizontal }}
{{ form.remote_addr|bootstrap_horizontal }}
{{ form.type|bootstrap_horizontal }}
{{ form.url|bootstrap_horizontal }}
{{ form.comment|bootstrap_horizontal }}
<div
class=
"hr-line-dashed"
></div>
<div
class=
"form-group"
>
<div
class=
"col-sm-4 col-sm-offset-2"
>
<button
class=
"btn btn-default"
type=
"reset"
>
{% trans 'Reset' %}
</button>
<button
id=
"submit_button"
class=
"btn btn-primary"
type=
"submit"
>
{% trans 'Submit' %}
</button>
</div>
</div>
</form>
{% endblock %}
{% block custom_foot_js %}
{% endblock %}
\ No newline at end of file
apps/applications/templates/applications/terminal_modal_accept.html
0 → 100644
浏览文件 @
d56f030d
{% extends '_modal.html' %}
{% load i18n %}
{% block modal_id %}modal_terminal_accept{% endblock %}
{% block modal_class %}modal-lg{% endblock %}
{% block modal_title%}{% trans "Accept terminal registration" %}{% endblock %}
{% block modal_body %}
{% load bootstrap %}
<form
action=
"{% url 'applications:terminal-modal-accept' pk="
99991937"
%}"
method=
"post"
class=
"form-horizontal"
id=
"form_terminal_accept"
>
{% csrf_token %}
{{ form.name|bootstrap_horizontal }}
{{ form.remote_addr|bootstrap_horizontal }}
{{ form.type|bootstrap_horizontal }}
{{ form.url|bootstrap_horizontal }}
{{ form.comment|bootstrap_horizontal }}
</form>
{% endblock %}
{% block modal_confirm_id %}btn_terminal_accept{% endblock %}
\ No newline at end of file
apps/applications/urls/views_urls.py
浏览文件 @
d56f030d
...
...
@@ -11,4 +11,5 @@ app_name = 'applications'
urlpatterns
=
[
url
(
r
'^terminal$'
,
views
.
TerminalListView
.
as_view
(),
name
=
'terminal-list'
),
url
(
r
'^terminal/(?P<pk>\d+)/update$'
,
views
.
TerminalUpdateView
.
as_view
(),
name
=
'terminal-update'
),
url
(
r
'^terminal/(?P<pk>\d+)/modal/accept$'
,
views
.
TerminalModelAccept
.
as_view
(),
name
=
'terminal-modal-accept'
),
]
apps/applications/views.py
浏览文件 @
d56f030d
# ~*~ coding: utf-8 ~*~
#
from
django.views.generic
import
ListView
,
UpdateView
,
DeleteView
from
django.views.generic
import
ListView
,
UpdateView
,
DeleteView
,
FormView
from
django.utils.translation
import
ugettext
as
_
from
django.urls
import
reverse_lazy
from
.models
import
Terminal
from
users.utils
import
AdminUserRequiredMixin
from
common.mixins
import
JSONResponseMixin
from
.forms
import
TerminalForm
class
TerminalListView
(
ListView
):
model
=
Terminal
template_name
=
'applications/terminal_list.html'
form_class
=
TerminalForm
def
get_context_data
(
self
,
**
kwargs
):
context
=
super
(
TerminalListView
,
self
).
get_context_data
(
**
kwargs
)
context
.
update
({
'app'
:
_
(
'Terminal'
),
'action'
:
_
(
'Terminal list'
)})
context
.
update
({
'app'
:
_
(
'Terminal'
),
'action'
:
_
(
'Terminal list'
),
'form'
:
self
.
form_class
()
})
return
context
...
...
@@ -34,4 +41,30 @@ class TerminalUpdateView(UpdateView):
class
TerminalDeleteView
(
DeleteView
):
model
=
Terminal
template_name
=
'assets/delete_confirm.html'
success_url
=
reverse_lazy
(
'applications:applications-list'
)
\ No newline at end of file
success_url
=
reverse_lazy
(
'applications:applications-list'
)
class
TerminalModelAccept
(
AdminUserRequiredMixin
,
JSONResponseMixin
,
UpdateView
):
model
=
Terminal
form_class
=
TerminalForm
def
form_valid
(
self
,
form
):
terminal
=
form
.
save
()
terminal
.
is_accepted
=
True
terminal
.
save
()
data
=
{
'success'
:
True
,
'msg'
:
'success'
}
print
(
'Valid'
)
return
self
.
render_json_response
(
data
)
def
form_invalid
(
self
,
form
):
print
(
form
.
errors
)
data
=
{
'success'
:
False
,
'msg'
:
','
.
join
(
form
.
errors
)
}
return
self
.
render_json_response
(
data
)
apps/templates/base.html
浏览文件 @
d56f030d
...
...
@@ -16,6 +16,7 @@
<body>
<div
id=
"wrapper"
>
{% include '_left_side_bar.html' %}
<div
id=
"page-wrapper"
class=
"gray-bg"
>
{% include '_header_bar.html' %}
...
...
apps/users/templates/users/user_list.html
浏览文件 @
d56f030d
...
...
@@ -132,8 +132,7 @@ $(document).ready(function(){
$form
.
ajaxSubmit
({
success
:
success
});
})
})
.
on
(
'
click
'
,
'
#btn_bulk_update
'
,
function
(){
}).
on
(
'
click
'
,
'
#btn_bulk_update
'
,
function
(){
var
action
=
$
(
'
#slct_bulk_update
'
).
val
();
var
$data_table
=
$
(
'
#user_list_table
'
).
DataTable
();
var
id_list
=
[];
...
...
@@ -205,15 +204,13 @@ $(document).ready(function(){
default
:
break
;
}
})
.
on
(
'
click
'
,
'
.btn_user_delete
'
,
function
(){
}).
on
(
'
click
'
,
'
.btn_user_delete
'
,
function
(){
var
$this
=
$
(
this
);
var
name
=
$this
.
data
(
'
name
'
);
var
uid
=
$this
.
data
(
'
uid
'
);
var
the_url
=
'
{% url "api-users:user-detail" pk=99991937 %}
'
.
replace
(
'
99991937
'
,
uid
);
objectDelete
(
$this
,
name
,
the_url
);
})
.
on
(
'
click
'
,
'
#btn_user_bulk_update
'
,
function
(){
}).
on
(
'
click
'
,
'
#btn_user_bulk_update
'
,
function
(){
var
json_data
=
$
(
'
#fm_user_bulk_update
'
).
serializeObject
();
var
body
=
{};
body
.
enable_otp
=
(
json_data
.
enable_otp
===
'
on
'
)?
true
:
false
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录