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
e3223f74
Commit
e3223f74
authored
Aug 15, 2016
by
广宏伟
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
app users
Modify user list view Modify user add view
parent
86ffcc97
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
65 additions
and
38 deletions
+65
-38
forms.py
apps/users/forms.py
+1
-1
models.py
apps/users/models.py
+4
-4
user_add.html
apps/users/templates/users/user_add.html
+13
-19
user_list.html
apps/users/templates/users/user_list.html
+3
-3
views.py
apps/users/views.py
+18
-1
table_design.xml
docs/table_design.xml
+26
-10
No files found.
apps/users/forms.py
View file @
e3223f74
...
...
@@ -10,6 +10,6 @@ class UserForm(ModelForm):
model
=
User
fields
=
[
'username'
,
'name'
,
'email'
,
'groups'
,
'wechat'
,
'phone'
,
'enable_2FA'
,
'role'
,
'comment'
,
'phone'
,
'enable_2FA'
,
'role'
,
'
date_expired'
,
'
comment'
,
]
apps/users/models.py
View file @
e3223f74
...
...
@@ -51,9 +51,9 @@ class UserGroup(models.Model):
class
User
(
AbstractUser
):
username
=
models
.
CharField
(
max_length
=
20
,
unique
=
True
,
verbose_name
=
'用户名'
)
name
=
models
.
CharField
(
max_length
=
20
,
verbose_name
=
'姓名'
)
email
=
models
.
EmailField
(
max_length
=
30
,
unique
=
True
,
verbose_name
=
'邮件'
)
username
=
models
.
CharField
(
max_length
=
20
,
unique
=
True
,
verbose_name
=
'用户名'
,
help_text
=
'* required'
)
name
=
models
.
CharField
(
max_length
=
20
,
verbose_name
=
'姓名'
,
help_text
=
'* required'
)
email
=
models
.
EmailField
(
max_length
=
30
,
unique
=
True
,
verbose_name
=
'邮件'
,
help_text
=
'* required'
)
groups
=
models
.
ManyToManyField
(
UserGroup
,
verbose_name
=
'用户组'
)
avatar
=
models
.
ImageField
(
verbose_name
=
'头像'
,
blank
=
True
)
wechat
=
models
.
CharField
(
max_length
=
30
,
blank
=
True
,
verbose_name
=
'微信'
)
...
...
@@ -65,7 +65,7 @@ class User(AbstractUser):
public_key
=
models
.
CharField
(
max_length
=
1000
,
blank
=
True
,
verbose_name
=
'公钥'
)
comment
=
models
.
CharField
(
max_length
=
200
,
blank
=
True
,
verbose_name
=
'描述'
)
created_by
=
models
.
CharField
(
max_length
=
30
,
default
=
''
)
date_expired
=
models
.
DateTimeField
(
default
=
datetime
.
datetime
.
max
)
date_expired
=
models
.
DateTimeField
(
default
=
datetime
.
datetime
.
max
,
verbose_name
=
'有效期'
)
class
Meta
:
db_table
=
'user'
apps/users/templates/users/user_add.html
View file @
e3223f74
...
...
@@ -21,44 +21,38 @@
</div>
</div>
<div
class=
"ibox-content"
>
<form
method=
"post"
id=
"userForm"
class=
"form-horizontal"
action=
""
>
<form
method=
"post"
id=
"userForm"
class=
"form-horizontal"
action=
"
{% url 'users:user-add' %}
"
>
{% csrf_token %}
<h
2>
账户
</h2
>
<h
3>
账户
</h3
>
{{ form.username|bootstrap_horizontal }}
{{ form.name|bootstrap_horizontal }}
{{ form.email|bootstrap_horizontal }}
{{ form.groups|bootstrap_horizontal }}
<div
class=
"hr-line-dashed"
></div>
<h
2>
密码
</h2
>
<h
3>
密码
</h3
>
<div
class=
"form-group"
>
<label
class=
"col-sm-2 control-label"
>
密码
</label>
<div
class=
"col-sm-8
bottom-left
"
>
<div
class=
"col-sm-8
controls
"
>
生成重置密码连接,通过邮件发送给用户
</div>
</div>
<div
class=
"hr-line-dashed"
></div>
<h2>
角色安全
</h2>
<h3>
角色安全
</h3>
{{ form.role|bootstrap_horizontal }}
{{ form.date_expired|bootstrap_horizontal }}
<div
class=
"form-group"
>
<label
for=
"
email"
class=
"col-sm-2 control-label"
>
Email
<span
class=
"red-fonts"
>
*
</span>
</label>
<label
for=
"
{{ form.enable_2FA.id_for_label }}"
class=
"col-sm-2 control-label"
>
二次验证
</label>
<div
class=
"col-sm-8"
>
<input
id=
"email"
name=
"email"
type=
"email"
placeholder=
"username@jumpserver.org"
class=
"form-control"
{%
if
error
%}
value=
"{{ email }}"
{%
endif
%}
>
{{ form.enable_2FA }}
</div>
</div>
<div
class=
"hr-line-dashed"
></div>
<div
class=
"form-group"
><label
class=
"col-sm-2 control-label"
>
其它
</label>
<div
class=
"col-sm-2"
>
<div
class=
"checkbox i-checks"
>
<label><input
type=
"checkbox"
value=
"0"
name=
"extra"
>
禁用
</label>
</div>
</div>
<div
class=
"col-sm-2"
>
<div
class=
"checkbox i-checks"
>
<label><input
type=
"checkbox"
value=
"1"
name=
"extra"
checked
>
发送邮件
</label>
</div>
</div>
</div>
<h3>
信息
</h3>
{{ form.phone|bootstrap_horizontal }}
{{ form.wechat|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"
>
...
...
apps/users/templates/users/user_list.html
View file @
e3223f74
...
...
@@ -21,11 +21,11 @@
<div
class=
"ibox-content"
>
<div
class=
""
>
<a
href=
"
#
"
class=
"btn btn-sm btn-primary "
>
添加用户
</a>
<a
href=
"
{% url 'users:user-add' %}
"
class=
"btn btn-sm btn-primary "
>
添加用户
</a>
<a
id=
"del_btn"
class=
"btn btn-sm btn-danger "
>
删除所选
</a>
<form
id=
"search_form"
method=
"get"
action=
""
class=
"pull-right mail-search"
>
<form
id=
"search_form"
method=
"get"
action=
"
{% url 'users:user-list' %}
"
class=
"pull-right mail-search"
>
<div
class=
"input-group"
>
<input
type=
"text"
class=
"form-control input-sm"
id=
"search_input"
name=
"keyword"
placeholder=
"Search
"
>
<input
type=
"text"
class=
"form-control input-sm"
name=
"keyword"
placeholder=
"用户名或姓名"
value=
"{{ keyword }}
"
>
<div
class=
"input-group-btn"
>
<button
id=
'search_btn'
type=
"submit"
class=
"btn btn-sm btn-primary"
>
搜索
...
...
apps/users/views.py
View file @
e3223f74
# ~*~ coding: utf-8 ~*~
from
django.urls
import
reverse_lazy
from
django.db.models
import
Q
from
django.views.generic.list
import
ListView
from
django.views.generic.edit
import
CreateView
...
...
@@ -12,10 +14,19 @@ class UserListView(ListView):
paginate_by
=
10
context_object_name
=
'user_list'
template_name
=
'users/user_list.html'
ordering
=
'-date_joined'
def
get_queryset
(
self
):
self
.
queryset
=
super
(
UserListView
,
self
)
.
get_queryset
()
self
.
keyword
=
keyword
=
self
.
request
.
GET
.
get
(
'keyword'
,
''
)
if
keyword
:
self
.
queryset
=
self
.
queryset
.
filter
(
Q
(
username__icontains
=
keyword
)
|
Q
(
name__icontains
=
keyword
))
return
self
.
queryset
def
get_context_data
(
self
,
**
kwargs
):
context
=
super
(
UserListView
,
self
)
.
get_context_data
(
**
kwargs
)
context
.
update
({
'path1'
:
'用户管理'
,
'path2'
:
'用户列表'
,
'title'
:
'用户列表'
})
context
.
update
({
'path1'
:
'用户管理'
,
'path2'
:
'用户列表'
,
'title'
:
'用户列表'
,
'keyword'
:
self
.
keyword
})
return
context
...
...
@@ -23,4 +34,10 @@ class UserAddView(CreateView):
model
=
User
form_class
=
UserForm
template_name
=
'users/user_add.html'
success_url
=
reverse_lazy
(
'users:user-list'
)
def
get_context_data
(
self
,
**
kwargs
):
context
=
super
(
UserAddView
,
self
)
.
get_context_data
(
**
kwargs
)
context
.
update
({
'path1'
:
'用户管理'
,
'path2'
:
'用户添加'
,
'title'
:
'用户添加'
})
return
context
docs/table_design.xml
View file @
e3223f74
...
...
@@ -37,7 +37,7 @@
<type
label=
"SET"
quote=
""
sql=
"SET"
length=
"1"
/>
<type
label=
"Bit"
quote=
""
sql=
"bit"
length=
"0"
/>
</group>
</datatypes><table
x=
"39
7
"
y=
"254"
name=
"user"
>
</datatypes><table
x=
"39
9
"
y=
"254"
name=
"user"
>
<row
name=
"id"
null=
"1"
autoincrement=
"1"
>
<datatype>
INTEGER
</datatype>
<default>
NULL
</default></row>
...
...
@@ -71,9 +71,12 @@
<row
name=
"is_active"
null=
"0"
autoincrement=
"0"
>
<datatype>
INTEGER
</datatype>
<default>
0
</default></row>
<row
name=
"
two_factor_auth
"
null=
"1"
autoincrement=
"0"
>
<row
name=
"
enable_2FA
"
null=
"1"
autoincrement=
"0"
>
<datatype>
INTEGER
</datatype>
<default>
0
</default></row>
<row
name=
"secret_key_2FA"
null=
"1"
autoincrement=
"0"
>
<datatype>
CHAR
</datatype>
<default>
NULL
</default></row>
<row
name=
"role"
null=
"1"
autoincrement=
"0"
>
<datatype>
INTEGER
</datatype>
<default>
NULL
</default><relation
table=
"role"
row=
"id"
/>
...
...
@@ -87,6 +90,9 @@
<row
name=
"public_key"
null=
"1"
autoincrement=
"0"
>
<datatype>
VARCHAR
</datatype>
<default>
NULL
</default></row>
<row
name=
"comment"
null=
"1"
autoincrement=
"0"
>
<datatype>
CHAR
</datatype>
<default>
NULL
</default></row>
<row
name=
"date_joined"
null=
"1"
autoincrement=
"0"
>
<datatype>
DATETIME
</datatype>
<default>
'now()'
</default></row>
...
...
@@ -223,6 +229,10 @@
<row
name=
"password"
null=
"1"
autoincrement=
"0"
>
<datatype>
VARCHAR
</datatype>
<default>
NULL
</default></row>
<row
name=
"admin_user"
null=
"1"
autoincrement=
"0"
>
<datatype>
INTEGER
</datatype>
<default>
NULL
</default><relation
table=
"adminuser"
row=
"id"
/>
</row>
<row
name=
"idc"
null=
"1"
autoincrement=
"0"
>
<datatype>
INTEGER
</datatype>
<default>
NULL
</default><relation
table=
"idc"
row=
"id"
/>
...
...
@@ -265,16 +275,18 @@
<row
name=
"disk"
null=
"1"
autoincrement=
"0"
>
<datatype>
VARCHAR
</datatype>
<default>
NULL
</default></row>
<row
name=
"is_active"
null=
"1"
autoincrement=
"0"
>
<datatype>
INTEGER
</datatype>
<default>
NULL
</default></row>
<row
name=
"comment"
null=
"1"
autoincrement=
"0"
>
<datatype>
CHAR
</datatype>
<default>
NULL
</default></row>
<row
name=
"created_by"
null=
"1"
autoincrement=
"0"
>
<datatype>
VARCHAR
</datatype>
<default>
NULL
</default></row>
<row
name=
"date_added"
null=
"1"
autoincrement=
"0"
>
<datatype>
DATETIME
</datatype>
<default>
NULL
</default></row>
<row
name=
"admin_user"
null=
"1"
autoincrement=
"0"
>
<datatype>
INTEGER
</datatype>
<default>
NULL
</default><relation
table=
"adminuser"
row=
"id"
/>
</row>
<key
type=
"PRIMARY"
name=
""
>
<part>
id
</part>
</key>
...
...
@@ -359,6 +371,9 @@
<row
name=
"comment"
null=
"1"
autoincrement=
"0"
>
<datatype>
VARCHAR
</datatype>
<default>
NULL
</default></row>
<row
name=
"created_by"
null=
"1"
autoincrement=
"0"
>
<datatype>
VARCHAR
</datatype>
<default>
NULL
</default></row>
<row
name=
"date_added"
null=
"1"
autoincrement=
"0"
>
<datatype>
DATETIME
</datatype>
<default>
NULL
</default></row>
...
...
@@ -519,7 +534,7 @@
<part>
id
</part>
</key>
</table>
<table
x=
"108
0"
y=
"886
"
name=
"task"
>
<table
x=
"108
1"
y=
"917
"
name=
"task"
>
<row
name=
"id"
null=
"1"
autoincrement=
"1"
>
<datatype>
INTEGER
</datatype>
<default>
NULL
</default></row>
...
...
@@ -623,7 +638,7 @@
<part>
id
</part>
</key>
</table>
<table
x=
"
297"
y=
"753
"
name=
"loginlog"
>
<table
x=
"
300"
y=
"770
"
name=
"loginlog"
>
<row
name=
"id"
null=
"1"
autoincrement=
"1"
>
<datatype>
INTEGER
</datatype>
<default>
NULL
</default></row>
...
...
@@ -652,7 +667,7 @@
<part>
id
</part>
</key>
</table>
<table
x=
"139"
y=
"7
57
"
name=
"adminlog"
>
<table
x=
"139"
y=
"7
72
"
name=
"adminlog"
>
<row
name=
"id"
null=
"1"
autoincrement=
"1"
>
<datatype>
INTEGER
</datatype>
<default>
NULL
</default></row>
...
...
@@ -678,7 +693,7 @@
<part>
id
</part>
</key>
</table>
<table
x=
"4
59"
y=
"752
"
name=
"proxylog"
>
<table
x=
"4
60"
y=
"769
"
name=
"proxylog"
>
<row
name=
"id"
null=
"1"
autoincrement=
"1"
>
<datatype>
INTEGER
</datatype>
<default>
NULL
</default></row>
...
...
@@ -775,3 +790,4 @@
</key>
</table>
</sql>
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