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
b35f1e61
Commit
b35f1e61
authored
Apr 02, 2015
by
halcyon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
权限申请
parent
e1b9134d
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
96 additions
and
15 deletions
+96
-15
models.py
jperm/models.py
+3
-0
urls.py
jperm/urls.py
+1
-0
views.py
jperm/views.py
+36
-9
settings.py
jumpserver/settings.py
+7
-6
perm_apply.html
templates/jperm/perm_apply.html
+8
-0
perm_apply_exec.html
templates/jperm/perm_apply_exec.html
+41
-0
No files found.
jperm/models.py
View file @
b35f1e61
import
datetime
import
datetime
from
uuidfield
import
UUIDField
from
django.db
import
models
from
django.db
import
models
from
juser.models
import
UserGroup
,
DEPT
from
juser.models
import
UserGroup
,
DEPT
from
jasset.models
import
Asset
,
BisGroup
from
jasset.models
import
Asset
,
BisGroup
...
@@ -36,6 +38,7 @@ class SudoPerm(models.Model):
...
@@ -36,6 +38,7 @@ class SudoPerm(models.Model):
class
Apply
(
models
.
Model
):
class
Apply
(
models
.
Model
):
uuid
=
UUIDField
(
auto
=
True
)
applyer
=
models
.
CharField
(
max_length
=
20
)
applyer
=
models
.
CharField
(
max_length
=
20
)
approver
=
models
.
CharField
(
max_length
=
20
)
approver
=
models
.
CharField
(
max_length
=
20
)
dept
=
models
.
CharField
(
max_length
=
20
)
dept
=
models
.
CharField
(
max_length
=
20
)
...
...
jperm/urls.py
View file @
b35f1e61
...
@@ -26,4 +26,5 @@ urlpatterns = patterns('jperm.views',
...
@@ -26,4 +26,5 @@ urlpatterns = patterns('jperm.views',
(
r'^cmd_edit/$'
,
'cmd_edit'
),
(
r'^cmd_edit/$'
,
'cmd_edit'
),
(
r'^apply/$'
,
'perm_apply'
),
(
r'^apply/$'
,
'perm_apply'
),
(
r'^apply_show/(\w+)/$'
,
'perm_apply_log'
),
(
r'^apply_show/(\w+)/$'
,
'perm_apply_log'
),
(
r'^apply_exec/$'
,
'perm_apply_exec'
),
)
)
jperm/views.py
View file @
b35f1e61
# coding: utf-8
# coding: utf-8
import
ast
import
sys
reload
(
sys
)
sys
.
setdefaultencoding
(
'utf8'
)
import
datetime
import
datetime
...
@@ -542,17 +544,25 @@ def perm_apply(request):
...
@@ -542,17 +544,25 @@ def perm_apply(request):
dept
=
DEPT
.
objects
.
get
(
id
=
dept_id
)
dept
=
DEPT
.
objects
.
get
(
id
=
dept_id
)
posts
=
Asset
.
objects
.
filter
(
dept
=
dept
)
posts
=
Asset
.
objects
.
filter
(
dept
=
dept
)
egroup
=
dept
.
bisgroup_set
.
all
()
egroup
=
dept
.
bisgroup_set
.
all
()
mail_address
=
'wangyong@fun.tv'
dept_da
=
User
.
objects
.
filter
(
dept_id
=
dept_id
,
role
=
'DA'
)
if
request
.
method
==
'POST'
:
if
request
.
method
==
'POST'
:
applyer
=
request
.
POST
.
get
(
'applyer'
)
applyer
=
request
.
POST
.
get
(
'applyer'
)
dept
=
request
.
POST
.
get
(
'dept'
)
dept
=
request
.
POST
.
get
(
'dept'
)
da
=
request
.
POST
.
get
(
'da'
)
group
=
request
.
POST
.
getlist
(
'group'
)
group
=
request
.
POST
.
getlist
(
'group'
)
hosts
=
request
.
POST
.
getlist
(
'hosts'
)
hosts
=
request
.
POST
.
getlist
(
'hosts'
)
comment
=
request
.
POST
.
get
(
'comment'
)
comment
=
request
.
POST
.
get
(
'comment'
)
print
applyer
,
dept
,
group
,
hosts
,
comment
da
=
User
.
objects
.
get
(
id
=
da
)
url
=
'http://127.0.0.1:8000/jperm/apply/exec/?id='
mail_address
=
da
.
email
mail_title
=
'权限申请'
mail_title
=
'
%
s - 权限申请'
%
username
# print da.username, applyer, group, hosts, datetime.datetime.now(), comment, url
group_lis
=
', '
.
join
(
group
)
hosts_lis
=
', '
.
join
(
hosts
)
time_now
=
datetime
.
datetime
.
now
()
.
strftime
(
'
%
Y-
%
m-
%
d
%
H:
%
M:
%
S'
)
Apply
.
objects
.
create
(
applyer
=
applyer
,
dept
=
dept
,
bisgroup
=
group
,
asset
=
hosts
,
status
=
0
,
comment
=
comment
)
uuid
=
Apply
.
objects
.
get
(
applyer
=
applyer
,
asset
=
hosts
,
comment
=
comment
)
.
uuid
url
=
"http://127.0.0.1:8000/jperm/apply_exec/?uuid=
%
s"
%
uuid
mail_msg
=
"""
mail_msg
=
"""
Hi,
%
s:
Hi,
%
s:
有新的权限申请, 详情如下:
有新的权限申请, 详情如下:
...
@@ -563,15 +573,32 @@ def perm_apply(request):
...
@@ -563,15 +573,32 @@ def perm_apply(request):
申请说明:
%
s
申请说明:
%
s
请及时审批, 审批完成后点击以下链接,告知各位。
请及时审批, 审批完成后点击以下链接,告知各位。
%
s
%
s
"""
%
(
u'123'
,
applyer
,
group
,
hosts
,
datetime
.
datetime
.
now
(),
comment
,
url
)
"""
%
(
da
.
username
,
applyer
,
group_lis
,
hosts_lis
,
time_now
,
comment
,
url
)
send_mail
(
mail_title
,
mail_msg
,
'jkfunshion@fun.tv'
,
[
mail_address
],
fail_silently
=
False
)
smg
=
"提交成功,已转交运维上线。"
Apply
.
objects
.
create
(
applyer
=
applyer
,
dept
=
dept
,
bisgroup
=
group
,
asset
=
hosts
,
status
=
0
,
comment
=
comment
)
send_mail
(
mail_title
,
mail_msg
,
'jkfunshion@fun.tv'
,
[
mail_address
],
fail_silently
=
False
)
smg
=
"提交成功,已发邮件通知部门管理员。"
return
render_to_response
(
'jperm/perm_apply.html'
,
locals
(),
context_instance
=
RequestContext
(
request
))
return
render_to_response
(
'jperm/perm_apply.html'
,
locals
(),
context_instance
=
RequestContext
(
request
))
return
render_to_response
(
'jperm/perm_apply.html'
,
locals
(),
context_instance
=
RequestContext
(
request
))
return
render_to_response
(
'jperm/perm_apply.html'
,
locals
(),
context_instance
=
RequestContext
(
request
))
def
perm_apply_exec
(
request
):
uuid
=
request
.
GET
.
get
(
'uuid'
)
p_apply
=
Apply
.
objects
.
filter
(
uuid
=
str
(
uuid
))
q_apply
=
Apply
.
objects
.
get
(
uuid
=
str
(
uuid
))
if
p_apply
:
user
=
User
.
objects
.
get
(
username
=
q_apply
.
applyer
)
mail_address
=
user
.
email
time_now
=
datetime
.
datetime
.
now
()
.
strftime
(
'
%
Y-
%
m-
%
d
%
H:
%
M:
%
S'
)
p_apply
.
update
(
status
=
1
,
date_end
=
time_now
)
mail_title
=
'
%
s - 权限审批完成'
%
q_apply
.
applyer
mail_msg
=
"""
Hi,
%
s:
您所申请的权限已由
%
s 在
%
s 审批完成, 请登录验证。
"""
%
(
q_apply
.
applyer
,
q_apply
.
approver
,
time_now
)
send_mail
(
mail_title
,
mail_msg
,
'jkfunshion@fun.tv'
,
[
mail_address
],
fail_silently
=
False
)
return
render_to_response
(
'jperm/perm_apply_exec.html'
,
locals
(),
context_instance
=
RequestContext
(
request
))
def
get_apply_posts
(
request
,
status
,
username
,
dept_name
,
keyword
=
None
):
def
get_apply_posts
(
request
,
status
,
username
,
dept_name
,
keyword
=
None
):
if
is_super_user
(
request
):
if
is_super_user
(
request
):
if
keyword
:
if
keyword
:
...
...
jumpserver/settings.py
View file @
b35f1e61
...
@@ -23,6 +23,13 @@ DB_USER = config.get('db', 'user')
...
@@ -23,6 +23,13 @@ DB_USER = config.get('db', 'user')
DB_PASSWORD
=
config
.
get
(
'db'
,
'password'
)
DB_PASSWORD
=
config
.
get
(
'db'
,
'password'
)
DB_DATABASE
=
config
.
get
(
'db'
,
'database'
)
DB_DATABASE
=
config
.
get
(
'db'
,
'database'
)
# mail config
EMAIL_HOST
=
'mail.funshion.com'
EMAIL_PORT
=
'25'
EMAIL_HOST_USER
=
'jkfunshion'
EMAIL_HOST_PASSWORD
=
'jkmail
%
'
EMAIL_USE_TLS
=
False
# Quick-start development settings - unsuitable for production
# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/1.7/howto/deployment/checklist/
# See https://docs.djangoproject.com/en/1.7/howto/deployment/checklist/
...
@@ -121,10 +128,4 @@ USE_TZ = False
...
@@ -121,10 +128,4 @@ USE_TZ = False
STATIC_URL
=
'/static/'
STATIC_URL
=
'/static/'
# mail config
EMAIL_HOST
=
config
.
get
(
'mail'
,
'email_host'
)
EMAIL_PORT
=
config
.
get
(
'mail'
,
'email_port'
)
EMAIL_HOST_USER
=
config
.
get
(
'mail'
,
'email_host_user'
)
EMAIL_HOST_PASSWORD
=
config
.
get
(
'mail'
,
'email_host_password'
)
EMAIL_USE_TLS
=
config
.
get
(
'mail'
,
'email_use_tls'
)
templates/jperm/perm_apply.html
View file @
b35f1e61
...
@@ -45,6 +45,14 @@
...
@@ -45,6 +45,14 @@
<div
class=
"col-sm-8"
><input
type=
"text"
name=
"dept"
value=
"{{ deptname }}"
class=
"form-control"
readonly=
"readonly"
></div>
<div
class=
"col-sm-8"
><input
type=
"text"
name=
"dept"
value=
"{{ deptname }}"
class=
"form-control"
readonly=
"readonly"
></div>
</div>
</div>
<div
class=
"hr-line-dashed"
></div>
<div
class=
"form-group"
><label
class=
"col-sm-2 control-label"
>
部门管理员
</label>
<div
class=
"radio"
>
{% for da in dept_da %}
<label><input
type=
"radio"
value=
"{{ da.id }}"
id=
"da"
name=
"da"
>
{{ da }}
</label>
{% endfor %}
</div>
</div>
<div
class=
"hr-line-dashed"
></div>
<div
class=
"hr-line-dashed"
></div>
<div
class=
"form-group"
>
<div
class=
"form-group"
>
...
...
templates/jperm/perm_apply_exec.html
0 → 100644
View file @
b35f1e61
{% extends 'base.html' %}
{% block content %}
{% include 'nav_cat_bar.html' %}
<!--<h3 class="text-center">项目发布申请</h3>-->
<div
class=
"wrapper wrapper-content animated fadeInRight"
>
<div
class=
"row"
>
<div
class=
"col-lg-10"
>
<div
id=
"add_asset"
class=
"ibox float-e-margins"
>
<div
id=
"ibox-content"
class=
"ibox-title"
>
<h5>
填写要申请主机的基本信息
</h5>
<div
class=
"ibox-tools"
>
<a
class=
"collapse-link"
>
<i
class=
"fa fa-chevron-up"
></i>
</a>
<a
class=
"dropdown-toggle"
data-toggle=
"dropdown"
href=
"#"
>
<i
class=
"fa fa-wrench"
></i>
</a>
<ul
class=
"dropdown-menu dropdown-user"
>
<li><a
href=
"#"
>
未启用 1
</a>
</li>
<li><a
href=
"#"
>
未启用 2
</a>
</li>
</ul>
<a
class=
"close-link"
>
<i
class=
"fa fa-times"
></i>
</a>
</div>
</div>
<div
class=
"ibox-content"
>
<h3>
授权完成, 已邮件通知申请人, 五秒钟后关闭页面
</h3>
</div>
</div>
</div>
</div>
</div>
<script>
</script>
{% endblock content %}
\ No newline at end of file
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