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
86ffcc97
Commit
86ffcc97
authored
Aug 14, 2016
by
广宏伟
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add user template
parent
9493fb07
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
209 additions
and
6 deletions
+209
-6
settings.py
apps/jumpserver/settings.py
+2
-0
forms.py
apps/users/forms.py
+15
-0
0003_auto_20160814_1758.py
apps/users/migrations/0003_auto_20160814_1758.py
+56
-0
models.py
apps/users/models.py
+4
-5
user_add.html
apps/users/templates/users/user_add.html
+122
-0
urls.py
apps/users/urls.py
+2
-1
views.py
apps/users/views.py
+8
-0
No files found.
apps/jumpserver/settings.py
View file @
86ffcc97
...
...
@@ -36,6 +36,7 @@ INSTALLED_APPS = [
'perms.apps.PermsConfig'
,
'ops.apps.OpsConfig'
,
'audits.apps.AuditsConfig'
,
'bootstrapform'
,
# 'django.contrib.admin',
'django.contrib.auth'
,
'django.contrib.contenttypes'
,
...
...
@@ -128,3 +129,4 @@ STATICFILES_DIRS = (
)
AUTH_USER_MODEL
=
'users.User'
BOOTSTRAP_COLUMN_COUNT
=
11
apps/users/forms.py
0 → 100644
View file @
86ffcc97
# ~*~ coding: utf-8 ~*~
from
django.forms
import
ModelForm
from
.models
import
User
,
UserGroup
class
UserForm
(
ModelForm
):
class
Meta
:
model
=
User
fields
=
[
'username'
,
'name'
,
'email'
,
'groups'
,
'wechat'
,
'phone'
,
'enable_2FA'
,
'role'
,
'comment'
,
]
apps/users/migrations/0003_auto_20160814_1758.py
0 → 100644
View file @
86ffcc97
# -*- coding: utf-8 -*-
# Generated by Django 1.10 on 2016-08-14 09:58
from
__future__
import
unicode_literals
from
django.db
import
migrations
,
models
class
Migration
(
migrations
.
Migration
):
dependencies
=
[
(
'users'
,
'0002_auto_20160814_1237'
),
]
operations
=
[
migrations
.
AddField
(
model_name
=
'user'
,
name
=
'name'
,
field
=
models
.
CharField
(
default
=
'guanghongwei'
,
max_length
=
20
),
preserve_default
=
False
,
),
migrations
.
AlterField
(
model_name
=
'user'
,
name
=
'avatar'
,
field
=
models
.
ImageField
(
blank
=
True
,
upload_to
=
b
''
,
verbose_name
=
'
\u5934\u50cf
'
),
),
migrations
.
AlterField
(
model_name
=
'user'
,
name
=
'created_by'
,
field
=
models
.
CharField
(
default
=
''
,
max_length
=
30
),
),
migrations
.
AlterField
(
model_name
=
'user'
,
name
=
'phone'
,
field
=
models
.
CharField
(
blank
=
True
,
max_length
=
20
,
verbose_name
=
'
\u624b\u673a\u53f7
'
),
),
migrations
.
AlterField
(
model_name
=
'user'
,
name
=
'private_key'
,
field
=
models
.
CharField
(
blank
=
True
,
max_length
=
5000
,
verbose_name
=
'ssh
\u79c1\u94a5
'
),
),
migrations
.
AlterField
(
model_name
=
'user'
,
name
=
'public_key'
,
field
=
models
.
CharField
(
blank
=
True
,
max_length
=
1000
,
verbose_name
=
'
\u516c\u94a5
'
),
),
migrations
.
AlterField
(
model_name
=
'user'
,
name
=
'secret_key_2FA'
,
field
=
models
.
CharField
(
blank
=
True
,
max_length
=
16
),
),
migrations
.
AlterField
(
model_name
=
'user'
,
name
=
'wechat'
,
field
=
models
.
CharField
(
blank
=
True
,
max_length
=
30
,
verbose_name
=
'
\u5fae\u4fe1
'
),
),
]
apps/users/models.py
View file @
86ffcc97
...
...
@@ -51,7 +51,10 @@ class UserGroup(models.Model):
class
User
(
AbstractUser
):
groups
=
models
.
ManyToManyField
(
UserGroup
)
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
=
'邮件'
)
groups
=
models
.
ManyToManyField
(
UserGroup
,
verbose_name
=
'用户组'
)
avatar
=
models
.
ImageField
(
verbose_name
=
'头像'
,
blank
=
True
)
wechat
=
models
.
CharField
(
max_length
=
30
,
blank
=
True
,
verbose_name
=
'微信'
)
phone
=
models
.
CharField
(
max_length
=
20
,
blank
=
True
,
verbose_name
=
'手机号'
)
...
...
@@ -64,9 +67,5 @@ class User(AbstractUser):
created_by
=
models
.
CharField
(
max_length
=
30
,
default
=
''
)
date_expired
=
models
.
DateTimeField
(
default
=
datetime
.
datetime
.
max
)
@property
def
name
(
self
):
return
self
.
first_name
+
self
.
last_name
class
Meta
:
db_table
=
'user'
apps/users/templates/users/user_add.html
0 → 100644
View file @
86ffcc97
{% extends 'base.html' %}
{% load bootstrap %}
{% block content %}
<div
class=
"wrapper wrapper-content animated fadeInRight"
>
<div
class=
"row"
>
<div
class=
"col-sm-12"
>
<div
class=
"ibox float-e-margins"
>
<div
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>
<a
class=
"close-link"
>
<i
class=
"fa fa-times"
></i>
</a>
</div>
</div>
<div
class=
"ibox-content"
>
<form
method=
"post"
id=
"userForm"
class=
"form-horizontal"
action=
""
>
{% csrf_token %}
<h2>
账户
</h2>
{{ form.username|bootstrap_horizontal }}
{{ form.name|bootstrap_horizontal }}
{{ form.email|bootstrap_horizontal }}
{{ form.groups|bootstrap_horizontal }}
<div
class=
"hr-line-dashed"
></div>
<h2>
密码
</h2>
<div
class=
"form-group"
>
<label
class=
"col-sm-2 control-label"
>
密码
</label>
<div
class=
"col-sm-8 bottom-left"
>
生成重置密码连接,通过邮件发送给用户
</div>
</div>
<div
class=
"hr-line-dashed"
></div>
<h2>
角色安全
</h2>
<div
class=
"form-group"
>
<label
for=
"email"
class=
"col-sm-2 control-label"
>
Email
<span
class=
"red-fonts"
>
*
</span></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
%}
>
</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>
<div
class=
"hr-line-dashed"
></div>
<div
class=
"form-group"
>
<div
class=
"col-sm-4 col-sm-offset-2"
>
<button
class=
"btn btn-white"
type=
"reset"
>
取消
</button>
<button
id=
"submit_button"
class=
"btn btn-primary"
type=
"submit"
>
确认保存
</button>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
{% endblock %}
{% block self_footer_js %}
<script>
$
(
'#userForm'
).
validator
({
timely
:
2
,
theme
:
"yellow_right_effect"
,
rules
:
{
check_username
:
[
/^
[\w
.
]{3,20}
$/
,
'大小写字母数字和下划线小数点'
],
type_m
:
function
(
element
){
return
$
(
"#M"
).
is
(
":checked"
);
}
},
fields
:
{
"username"
:
{
rule
:
"required;check_username"
,
tip
:
"输入用户名"
,
ok
:
""
,
msg
:
{
required
:
"必须填写!"
}
},
"password"
:
{
rule
:
"required;length[6~50]"
,
tip
:
"输入密码"
,
ok
:
""
,
msg
:
{
required
:
"必须填写!"
}
},
"name"
:
{
rule
:
"required"
,
tip
:
"姓名"
,
ok
:
""
,
msg
:
{
required
:
"必须填写"
}
},
"email"
:
{
rule
:
"required"
,
tip
:
"Email"
,
ok
:
""
,
msg
:
{
required
:
"必须填写"
}
}
},
valid
:
function
(
form
)
{
form
.
submit
();
}
});
</script>
{% endblock %}
\ No newline at end of file
apps/users/urls.py
View file @
86ffcc97
from
django.conf.urls
import
url
from
.views
import
UserListView
from
.views
import
UserListView
,
UserAddView
app_name
=
'users'
urlpatterns
=
[
url
(
r'^$'
,
UserListView
.
as_view
(),
name
=
'user-list'
),
url
(
r'^(?P<pk>[0-9]+)/$'
,
UserListView
.
as_view
(),
name
=
'user-detail'
),
url
(
r'^add/$'
,
UserAddView
.
as_view
(),
name
=
'user-add'
),
url
(
r'^(?P<pk>[0-9]+)/edit/$'
,
UserListView
.
as_view
(),
name
=
'user-edit'
),
url
(
r'^(?P<pk>[0-9]+)/delete/$'
,
UserListView
.
as_view
(),
name
=
'user-delete'
),
]
apps/users/views.py
View file @
86ffcc97
# ~*~ coding: utf-8 ~*~
from
django.views.generic.list
import
ListView
from
django.views.generic.edit
import
CreateView
from
.models
import
User
,
UserGroup
from
.forms
import
UserForm
class
UserListView
(
ListView
):
...
...
@@ -16,3 +18,9 @@ class UserListView(ListView):
context
.
update
({
'path1'
:
'用户管理'
,
'path2'
:
'用户列表'
,
'title'
:
'用户列表'
})
return
context
class
UserAddView
(
CreateView
):
model
=
User
form_class
=
UserForm
template_name
=
'users/user_add.html'
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