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
73d61e09
Commit
73d61e09
authored
Sep 16, 2014
by
guanghongwei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
添加forms
parent
45b874fc
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
71 additions
and
17 deletions
+71
-17
views.py
webroot/AutoSa/AutoSa/views.py
+3
-1
forms.py
webroot/AutoSa/UserManage/forms.py
+31
-0
models.py
webroot/AutoSa/UserManage/models.py
+1
-0
addUser.html
webroot/AutoSa/templates/addUser.html
+36
-16
No files found.
webroot/AutoSa/AutoSa/views.py
View file @
73d61e09
...
@@ -12,6 +12,8 @@ from binascii import b2a_hex, a2b_hex
...
@@ -12,6 +12,8 @@ from binascii import b2a_hex, a2b_hex
import
random
import
random
import
ConfigParser
import
ConfigParser
import
pam
import
pam
from
UserManage.forms
import
UserAddForm
,
GroupAddFrom
base_dir
=
"/opt/jumpserver/"
base_dir
=
"/opt/jumpserver/"
...
@@ -165,7 +167,7 @@ def addUser(request):
...
@@ -165,7 +167,7 @@ def addUser(request):
"""添加用户"""
"""添加用户"""
jm
=
PyCrypt
(
key
)
jm
=
PyCrypt
(
key
)
if
request
.
method
==
'GET'
:
if
request
.
method
==
'GET'
:
return
render_to_response
(
'addUser.html'
,
{
'user_menu'
:
'active'
},
return
render_to_response
(
'addUser.html'
,
{
'user_menu'
:
'active'
,
'form'
:
UserAddForm
},
context_instance
=
RequestContext
(
request
))
context_instance
=
RequestContext
(
request
))
else
:
else
:
username
=
request
.
POST
.
get
(
'username'
)
username
=
request
.
POST
.
get
(
'username'
)
...
...
webroot/AutoSa/UserManage/forms.py
0 → 100644
View file @
73d61e09
# coding: utf-8
from
django
import
forms
from
UserManage.models
import
Group
class
GroupAddForm
(
forms
.
Form
):
name
=
forms
.
CharField
(
max_length
=
30
)
class
UserAddForm
(
forms
.
Form
):
username
=
forms
.
CharField
(
max_length
=
30
,
widget
=
forms
.
TextInput
(
attrs
=
{
'class'
:
'form-control'
,
'placeholder'
:
'用户名'
}))
password
=
forms
.
CharField
(
max_length
=
30
,
widget
=
forms
.
PasswordInput
(
attrs
=
{
'class'
:
'form-control'
,
'placeholder'
:
'密码'
}))
password_again
=
forms
.
CharField
(
max_length
=
30
,
widget
=
forms
.
PasswordInput
(
attrs
=
{
'class'
:
'form-control'
,
'placeholder'
:
'确认密码'
}))
key_pass
=
forms
.
CharField
(
max_length
=
30
,
widget
=
forms
.
PasswordInput
(
attrs
=
{
'class'
:
'form-control'
,
'placeholder'
:
'密钥密码'
}))
key_pass_again
=
forms
.
CharField
(
max_length
=
30
,
widget
=
forms
.
PasswordInput
(
attrs
=
{
'class'
:
'form-control'
,
'placeholder'
:
'确认密码'
}))
name
=
forms
.
CharField
(
max_length
=
30
,
widget
=
forms
.
TextInput
(
attrs
=
{
'class'
:
'form-control'
,
'placeholder'
:
'姓名'
}))
group
=
forms
.
ModelMultipleChoiceField
(
queryset
=
Group
.
objects
.
all
(),
widget
=
forms
.
MultipleChoiceField
(
attrs
=
{
'class'
:
'form-control'
}))
is_admin
=
forms
.
BooleanField
()
is_superuser
=
forms
.
BooleanField
()
webroot/AutoSa/UserManage/models.py
View file @
73d61e09
...
@@ -11,6 +11,7 @@ class Group(models.Model):
...
@@ -11,6 +11,7 @@ class Group(models.Model):
class
User
(
models
.
Model
):
class
User
(
models
.
Model
):
username
=
models
.
CharField
(
max_length
=
50
)
username
=
models
.
CharField
(
max_length
=
50
)
password
=
models
.
CharField
(
max_length
=
100
)
password
=
models
.
CharField
(
max_length
=
100
)
key_pass
=
models
.
CharField
(
max_length
=
100
)
name
=
models
.
CharField
(
max_length
=
50
)
name
=
models
.
CharField
(
max_length
=
50
)
group
=
models
.
ManyToManyField
(
Group
)
group
=
models
.
ManyToManyField
(
Group
)
is_admin
=
models
.
BooleanField
()
is_admin
=
models
.
BooleanField
()
...
...
webroot/AutoSa/templates/addUser.html
View file @
73d61e09
...
@@ -3,56 +3,76 @@
...
@@ -3,56 +3,76 @@
<form
class=
"form-horizontal"
role=
"form"
method=
"post"
action=
""
>
<form
class=
"form-horizontal"
role=
"form"
method=
"post"
action=
""
>
<fieldset
>
<fieldset
>
<legend>
添加用户
</legend>
<legend>
添加用户
</legend>
{% if
error
%}
{% if
form.errors
%}
<div
class=
"alert alert-danger"
>
<div
class=
"alert alert-danger"
>
{{ error }}
Please correct the error{{ form.errors|pluralize }} below.
</div>
</div>
{% endif %}
{% endif %}
{% if msg %}
{% if msg %}
<div
class=
"alert alert-success"
>
<div
class=
"alert alert-success"
>
{{ msg }}
{{ msg }}
</div>
</div>
{% endif %}
{% endif %}
<div
class=
"form-group"
>
<div
class=
"form-group"
>
<label
for=
"username"
class=
"col-sm-2 control-label"
>
用户名
<span
style=
"color: red"
>
*
</span></label>
{{ form.username.errors }}
<label
for=
"id_username"
class=
"col-sm-2 control-label"
>
用户名
<span
style=
"color: red"
>
*
</span></label>
<div
class=
"col-sm-4"
>
<div
class=
"col-sm-4"
>
<input
type=
"text"
class=
"form-control"
id=
"username"
name=
"username"
placeholder=
"用户名"
>
{{ form.username }}
</div>
</div>
</div>
</div>
<div
class=
"form-group"
>
<div
class=
"form-group"
>
<label
for=
"password"
class=
"col-sm-2 control-label"
>
密码
<span
style=
"color: red"
>
*
</span></label>
{{ form.password.errors }}
<label
for=
"id_password"
class=
"col-sm-2 control-label"
>
密码
<span
style=
"color: red"
>
*
</span></label>
<div
class=
"col-sm-4"
>
<div
class=
"col-sm-4"
>
<input
type=
"password"
class=
"form-control"
id=
"password"
name=
"password"
placeholder=
"密码"
>
{{ form.password }}
</div>
</div>
</div>
</div>
<div
class=
"form-group"
>
<div
class=
"form-group"
>
<label
for=
"password_confirm"
class=
"col-sm-2 control-label"
>
确认密码
<span
style=
"color: red"
>
*
</span></label>
{{ form.password_again.errors }}
<label
for=
"id_password_again"
class=
"col-sm-2 control-label"
>
确认密码
<span
style=
"color: red"
>
*
</span></label>
<div
class=
"col-sm-4"
>
<div
class=
"col-sm-4"
>
<input
type=
"password"
class=
"form-control"
id=
"password_confirm"
name=
"password_confirm"
placeholder=
"确认密码"
>
{{ form.password_again }}
</div>
</div>
</div>
</div>
<div
class=
"form-group"
>
<div
class=
"form-group"
>
<label
for=
"keypass"
class=
"col-sm-2 control-label"
>
Key密码
<span
style=
"color: red"
>
*
</span></label>
{{ form.key_pass.errors }}
<label
for=
"id_keypass"
class=
"col-sm-2 control-label"
>
密钥密码
<span
style=
"color: red"
>
*
</span></label>
<div
class=
"col-sm-4"
>
<div
class=
"col-sm-4"
>
<input
type=
"password"
class=
"form-control"
id=
"keypass"
name=
"keypass"
placeholder=
"Key密码"
>
{{ form.key_pass }}
</div>
</div>
</div>
</div>
<div
class=
"form-group"
>
<div
class=
"form-group"
>
<label
for=
"keypass_confirm"
class=
"col-sm-2 control-label"
>
确认密码
<span
style=
"color: red"
>
*
</span></label>
{{ form.key_pass_again.errors }}
<label
for=
"id_keypass_again"
class=
"col-sm-2 control-label"
>
确认密码
<span
style=
"color: red"
>
*
</span></label>
<div
class=
"col-sm-4"
>
<div
class=
"col-sm-4"
>
<input
type=
"password"
class=
"form-control"
id=
"keypass_confirm"
name=
"keypass_confirm"
placeholder=
"确认密码"
>
{{ form.key_pass_again }}
</div>
</div>
</div>
</div>
<div
class=
"form-group"
>
<div
class=
"form-group"
>
<label
for=
"name"
class=
"col-sm-2 control-label"
>
姓名
<span
style=
"color: red"
>
*
</span></label>
{{ form.name.errors }}
<label
for=
"id_name"
class=
"col-sm-2 control-label"
>
姓名
<span
style=
"color: red"
>
*
</span></label>
<div
class=
"col-sm-4"
>
<div
class=
"col-sm-4"
>
<input
type=
"text"
class=
"form-control"
id=
"name"
name=
'name'
placeholder=
"姓名"
>
{{ form.name }}
</div>
</div>
</div>
</div>
<div
class=
"form-group"
>
<div
class=
"form-group"
>
<label
for=
"email"
class=
"col-sm-2 control-label"
>
E-mail
</label>
{{ form.group.errors }}
<label
for=
"id_group"
class=
"col-sm-2 control-label"
>
属组
</label>
<div
class=
"col-sm-4"
>
<div
class=
"col-sm-4"
>
<input
type=
"email"
class=
"form-control"
id=
"email"
name=
"email"
placeholder=
"用户名"
>
{{ form.group }}
</div>
</div>
<div
class=
"form-group"
>
<label
for=
"id_is_admin"
class=
"col-sm-2 control-label"
>
组admin
</label>
<div
class=
"col-sm-4"
>
{{ form.is_admin }}
</div>
</div>
<div
class=
"form-group"
>
<label
for=
"id_is_superuser"
class=
"col-sm-2 control-label"
>
超级admin
</label>
<div
class=
"col-sm-4"
>
{{ form.is_superuser }}
</div>
</div>
</div>
</div>
<div
class=
"form-group"
>
<div
class=
"form-group"
>
...
...
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