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
25d9dbe9
Commit
25d9dbe9
authored
Sep 06, 2016
by
ibuler
Browse files
Options
Browse Files
Download
Plain Diff
Merge with cmdb
parents
02b5483d
3c6f50b7
Show whitespace changes
Inline
Side-by-side
Showing
17 changed files
with
195 additions
and
216 deletions
+195
-216
forms.py
apps/assets/forms.py
+1
-1
asset_group_list.html
apps/assets/templates/assets/asset_group_list.html
+1
-1
django.mo
apps/locale/zh/LC_MESSAGES/django.mo
+0
-0
django.po
apps/locale/zh/LC_MESSAGES/django.po
+109
-108
_header_bar.html
apps/templates/_header_bar.html
+7
-1
_user_profile.html
apps/templates/_user_profile.html
+1
-1
forms.py
apps/users/forms.py
+13
-8
models.py
apps/users/models.py
+1
-1
_user.html
apps/users/templates/users/_user.html
+1
-1
forgot_password.html
apps/users/templates/users/forgot_password.html
+1
-1
login.html
apps/users/templates/users/login.html
+4
-8
user_detail.html
apps/users/templates/users/user_detail.html
+3
-3
user_list.html
apps/users/templates/users/user_list.html
+3
-3
user_update.html
apps/users/templates/users/user_update.html
+1
-0
urls.py
apps/users/urls.py
+31
-11
utils.py
apps/users/utils.py
+2
-2
views.py
apps/users/views.py
+16
-66
No files found.
apps/assets/forms.py
View file @
25d9dbe9
...
...
@@ -16,7 +16,7 @@ class AssetForm(forms.ModelForm):
]
widgets
=
{
'groups'
:
forms
.
SelectMultiple
(
attrs
=
{
'class'
:
'select2'
,
'data-placeholder'
:
_
(
'
Join asset
groups'
)}),
'groups'
:
forms
.
SelectMultiple
(
attrs
=
{
'class'
:
'select2'
,
'data-placeholder'
:
_
(
'
Select asset
groups'
)}),
}
...
...
apps/assets/templates/assets/asset_group_list.html
View file @
25d9dbe9
...
...
@@ -29,7 +29,7 @@
<td
class=
"text-center"
>
{{ asset_group.assets.count }}
</td>
<td
class=
"text-center"
>
{{ asset_group.comment }}
</td>
<td
class=
"text-center"
>
<a
href=
"{% url 'assets:asset-group-update' pk=asset_group.id %}"
class=
"btn btn-xs btn-info"
>
{% trans '
Edit
' %}
</a>
<a
href=
"{% url 'assets:asset-group-update' pk=asset_group.id %}"
class=
"btn btn-xs btn-info"
>
{% trans '
Update
' %}
</a>
<a
href=
"{% url 'assets:asset-group-delete' pk=asset_group.id %}"
class=
"btn btn-xs btn-danger del"
>
{% trans 'Delete' %}
</a>
</td>
</tr>
...
...
apps/locale/zh/LC_MESSAGES/django.mo
View file @
25d9dbe9
No preview for this file type
apps/locale/zh/LC_MESSAGES/django.po
View file @
25d9dbe9
...
...
@@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: Jumpserver 0.3.3\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2016-09-0
5 20:1
8+0800\n"
"POT-Creation-Date: 2016-09-0
6 15:0
8+0800\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: ibuler <ibuler@qq.com>\n"
"Language-Team: Jumpserver team<ibuler@qq.com>\n"
...
...
@@ -17,12 +17,20 @@ msgstr ""
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
#: assets/forms.py:20
msgid "Join assetgroups"
msgstr "添加到用户组"
#: assets/forms.py:19
msgid "Select asset groups"
msgstr "添加到资产组"
#: assets/forms.py:25 assets/models.py:144 templates/_nav.html:21
msgid "Asset"
msgstr "资产"
#: assets/forms.py:28
msgid "Select assets"
msgstr "选择资产"
#: assets/models.py:9 assets/models.py:21 assets/models.py:54
#: assets/models.py:76 assets/templates/assets/assetgroup_list.html:12
#: assets/models.py:76 assets/templates/assets/asset
_
group_list.html:12
#: users/models.py:60 users/models.py:107
#: users/templates/users/user_detail.html:69
#: users/templates/users/user_list.html:12
...
...
@@ -38,7 +46,7 @@ msgstr "创建者"
#: assets/models.py:11 assets/models.py:30 assets/models.py:44
#: assets/models.py:62 assets/models.py:91 assets/models.py:128
#: assets/models.py:147 assets/templates/assets/assetgroup_list.html:14
#: assets/models.py:147 assets/templates/assets/asset
_
group_list.html:14
#: users/models.py:61 users/models.py:118
#: users/templates/users/user_detail.html:113
msgid "Comment"
...
...
@@ -81,20 +89,21 @@ msgstr "KEY"
msgid "VALUE"
msgstr "VALUE"
#: assets/models.py:55 assets/models.py:77 users/forms.py:1
2
#: users/models.py:106 users/templates/users/login.html:5
4
#: assets/models.py:55 assets/models.py:77 users/forms.py:1
3
#: users/models.py:106 users/templates/users/login.html:5
3
#: users/templates/users/user_detail.html:73
#: users/templates/users/user_edit.html:5
#: users/templates/users/user_list.html:13
#: users/templates/users/user_update.html:6
msgid "Username"
msgstr "用户名"
#: assets/models.py:56 assets/models.py:78 users/forms.py:1
3
#: users/templates/users/login.html:5
7
#: assets/models.py:56 assets/models.py:78 users/forms.py:1
5
#: users/templates/users/login.html:5
6
#: users/templates/users/reset_password.html:52
#: users/templates/users/user_add.html:8 users/templates/users/user_add.html:10
#: users/templates/users/user_edit.html:12
#: users/templates/users/user_edit.html:14
#: users/templates/users/user_create.html:8
#: users/templates/users/user_create.html:10
#: users/templates/users/user_update.html:13
#: users/templates/users/user_update.html:15
msgid "Password"
msgstr "密码"
...
...
@@ -130,7 +139,7 @@ msgstr "Sudo"
msgid "Shell"
msgstr "Shell"
#: assets/models.py:87 templates/_header_bar.html:
35
templates/_nav.html:4
#: assets/models.py:87 templates/_header_bar.html:
41
templates/_nav.html:4
msgid "Home"
msgstr "仪表盘"
...
...
@@ -170,6 +179,10 @@ msgstr "管理用户"
msgid "Admin password"
msgstr "管理员密码"
#: assets/models.py:110
msgid "System User"
msgstr "系统用户"
#: assets/models.py:111 templates/_nav.html:23
msgid "IDC"
msgstr "机房"
...
...
@@ -230,75 +243,72 @@ msgstr "序列号"
msgid "Is active"
msgstr "是否激活"
#: assets/models.py:144 assets/templates/assets/assetgroup_add.html:35
#: templates/_nav.html:21
msgid "Asset"
msgstr "资产"
#: assets/templates/assets/assetgroup_add.html:16
#: assets/templates/assets/assetgroup_list.html:5 assets/views.py:60
#: assets/templates/assets/asset_group_create.html:16
#: assets/templates/assets/asset_group_list.html:5 assets/views.py:60
#: assets/views.py:98
msgid "Create asset group"
msgstr "创建资产组"
#: assets/templates/assets/assetgroup_add.html:37
msgid "Select asset"
msgstr "选择资产"
#: assets/templates/assets/assetgroup_add.html:49
#: assets/templates/assets/asset_group_create.html:50
#: users/templates/users/_user.html:70
#: users/templates/users/user_detail.html:162
#: users/templates/users/user_detail.html:170
msgid "Reset"
msgstr "重置"
#: assets/templates/assets/asset
group_add.html:50
#: assets/templates/assets/assetgroup_list.html:51
#: assets/templates/assets/asset
_group_create.html:51
#: assets/templates/assets/asset
_
group_list.html:51
#: users/templates/users/_user.html:71
#: users/templates/users/forg
e
t_password.html:44
#: users/templates/users/forg
o
t_password.html:44
#: users/templates/users/user_list.html:63
msgid "Submit"
msgstr "提交"
#: assets/templates/assets/assetgroup_list.html:13
#: assets/templates/assets/asset
_
group_list.html:13
#: users/templates/users/user_list.html:16
msgid "Asset num"
msgstr "资产数量"
#: assets/templates/assets/assetgroup_list.html:32
#: assets/templates/assets/asset
_
group_list.html:32
#: users/templates/users/user_list.html:44
msgid "
Edit
"
msgstr "
编辑
"
msgid "
Update
"
msgstr "
更新
"
#: assets/templates/assets/assetgroup_list.html:33
#: assets/templates/assets/asset
_
group_list.html:33
#: users/templates/users/user_list.html:45
msgid "Delete"
msgstr "删除"
#: assets/templates/assets/assetgroup_list.html:43
#: assets/templates/assets/asset
_
group_list.html:43
#: users/templates/users/user_list.html:55
msgid "Delete selected"
msgstr "批量删除"
#: assets/templates/assets/assetgroup_list.html:44
#: assets/templates/assets/asset
_
group_list.html:44
#: users/templates/users/user_list.html:56
msgid "Update selected"
msgstr "批量更新"
#: assets/templates/assets/assetgroup_list.html:45
#: assets/templates/assets/asset
_
group_list.html:45
#: users/templates/users/user_list.html:57
msgid "Deactive selected"
msgstr "禁用所选"
#: assets/templates/assets/assetgroup_list.html:46
#: assets/templates/assets/asset
_
group_list.html:46
#: users/templates/users/user_list.html:58
msgid "Export selected"
msgstr "批量导出"
#: assets/views.py:59 assets/views.py:74 templates/_nav.html:18
#: assets/templates/assets/asset_list.html:27
msgid "Create asset"
msgstr "创建资产"
#: assets/views.py:59 assets/views.py:78 assets/views.py:97
#: templates/_nav.html:18
msgid "Assets"
msgstr "资产管理"
#: assets/views.py:7
5
#: assets/views.py:7
9
msgid "Asset group list"
msgstr "资产组列表"
...
...
@@ -314,16 +324,27 @@ msgstr "欢迎使用Jumpserver开源跳板机系统"
msgid "Help"
msgstr "帮助"
#: templates/_nav.html:9 users/views.py:100 users/views.py:113
#: users/views.py:153 users/views.py:170 users/views.py:195 users/views.py:208
#: templates/_header_bar.html:24 templates/_user_profile.html:21
msgid "Logout"
msgstr "注销登录"
#: templates/_header_bar.html:28 users/templates/users/login.html:42
#: users/templates/users/login.html:61
msgid "Login"
msgstr "登录"
#: templates/_nav.html:9 users/views.py:50 users/views.py:63 users/views.py:103
#: users/views.py:120 users/views.py:145 users/views.py:158
msgid "Users"
msgstr "用户管理"
#: templates/_nav.html:12 users/models.py:103
#: templates/_nav.html:12
templates/_user_profile.html:14
users/models.py:103
msgid "User"
msgstr "用户"
#: templates/_nav.html:13
#: templates/_nav.html:13 users/models.py:109
#: users/templates/users/user_detail.html:181
#: users/templates/users/user_list.html:15
msgid "User group"
msgstr "用户组"
...
...
@@ -379,10 +400,6 @@ msgstr "访问官网"
msgid "Profile"
msgstr "个人信息"
#: templates/_user_profile.html:21
msgid "Logout"
msgstr "注销登录"
#: templates/captcha/image.html:3
msgid "Play CAPTCHA as audio file"
msgstr ""
...
...
@@ -391,7 +408,8 @@ msgstr ""
msgid "Captcha"
msgstr "验证码"
#: users/forms.py:31 users/forms.py:50
#: users/forms.py:34 users/forms.py:54
#: users/templates/users/user_detail.html:189
msgid "Join user groups"
msgstr "添加到用户组"
...
...
@@ -403,11 +421,6 @@ msgstr "管理员"
msgid "Email"
msgstr "邮件"
#: users/models.py:109 users/templates/users/user_detail.html:181
#: users/templates/users/user_list.html:15
msgid "Usergroup"
msgstr "用户组"
#: users/models.py:110 users/templates/users/user_detail.html:93
#: users/templates/users/user_list.html:14
msgid "Role"
...
...
@@ -446,7 +459,7 @@ msgid "System"
msgstr "系统"
#: users/templates/users/_user.html:17 users/templates/users/user_list.html:5
#: users/views.py:
11
3
#: users/views.py:
6
3
msgid "Create user"
msgstr "创建用户"
...
...
@@ -458,18 +471,15 @@ msgstr "账户"
msgid "Security and Role"
msgstr "角色安全"
#: users/templates/users/forget_password.html:26
msgid "Forget password"
#: users/templates/users/forgot_password.html:26
#: users/templates/users/login.html:64
msgid "Forgot password"
msgstr "忘记密码"
#: users/templates/users/forg
e
t_password.html:33
#: users/templates/users/forg
o
t_password.html:33
msgid "Input your email, that will send a mail to your"
msgstr "输入您的邮箱, 将会发一封重置短信邮件到您的邮箱中"
#: users/templates/users/login.html:42 users/templates/users/login.html:62
msgid "Login"
msgstr "登录"
#: users/templates/users/login.html:47
msgid "Captcha invalid"
msgstr "验证码错误"
...
...
@@ -487,7 +497,7 @@ msgstr "再次输入密码"
msgid "Setting"
msgstr "设置"
#: users/templates/users/user_
add
.html:12
#: users/templates/users/user_
create
.html:12
msgid "Reset link will be generated and sent to the user. "
msgstr "生成重置密码连接,通过邮件发送给用户"
...
...
@@ -495,7 +505,7 @@ msgstr "生成重置密码连接,通过邮件发送给用户"
msgid "Confirm delete"
msgstr "确认删除"
#: users/templates/users/user_detail.html:18 users/views.py:1
7
0
#: users/templates/users/user_detail.html:18 users/views.py:1
2
0
msgid "User detail"
msgstr "用户详情"
...
...
@@ -523,18 +533,31 @@ msgstr "快速修改"
msgid "Reset ssh key"
msgstr "重置密钥"
#: users/templates/users/user_detail.html:189
msgid "Select usergroups"
msgstr "选择用户组"
#: users/templates/users/user_detail.html:198
msgid "Add"
msgstr "添加"
msgid "Join"
msgstr "加入"
#: users/templates/users/user_group_create.html:16 users/views.py:158
msgid "Create user group"
msgstr "创建用户组"
#: users/templates/users/user_list.html:17
#, fuzzy
msgid "Active"
msgstr "激活"
#: users/templates/users/user_update.html:3 users/views.py:103
msgid "Update user"
msgstr "编辑用户"
#: users/urls.py:23
msgid "Logout success"
msgstr "退出登录成功"
#: users/urls.py:24
msgid "Logout success, return login page"
msgstr "退出登录成功,返回到登录页面"
#: users/utils.py:47
msgid "Begin to generate ssh private key ..."
msgstr "开始生成ssh密钥"
...
...
@@ -636,69 +659,47 @@ msgstr ""
" </br>\n"
" "
#: users/views.py:53
msgid "Username or password invalid"
msgstr "用户名或密码错误"
#: users/views.py:70
msgid "Logout success"
msgstr "退出登录成功"
#: users/views.py:71
msgid "Logout success, return login page"
msgstr "退出登录成功,返回到登录页面"
#: users/views.py:100
#: users/views.py:50
msgid "User list"
msgstr "用户列表"
#: users/views.py:
10
9
#: users/views.py:
5
9
#, python-format
msgid "Create user<a href=\"%s\">%s</a> success."
msgstr "创建用户<a href=\"%s\">%s</a> 成功"
msgid "Create user
<a href=\"%s\">%s</a> success."
msgstr "创建用户
<a href=\"%s\">%s</a> 成功"
#: users/views.py:153
msgid "Edit user"
msgstr "编辑用户"
#: users/views.py:195
msgid "Usergroup list"
#: users/views.py:145
msgid "User group list"
msgstr "用户组列表"
#: users/views.py:208
msgid "Create usergroup"
msgstr "创建用户组"
#: users/views.py:240
#: users/views.py:190
msgid "Email address invalid, input again"
msgstr "邮箱地址错误,重新输入"
#: users/views.py:2
5
1
#: users/views.py:2
0
1
msgid "Send reset password message"
msgstr "发送重置密码邮件"
#: users/views.py:2
5
2
#: users/views.py:2
0
2
msgid "Send reset password mail success, login your mail box and follow it "
msgstr ""
"发送重置邮件成功, 请登录邮箱查看, 按照提示操作 (如果没收到,请等待3-5分钟)"
#: users/views.py:2
6
4
#: users/views.py:2
1
4
msgid "Reset password success"
msgstr "重置密码成功"
#: users/views.py:2
6
5
#: users/views.py:2
1
5
msgid "Reset password success, return to login page"
msgstr "重置密码成功,返回到登录页面"
#: users/views.py:2
81 users/views.py:29
4
#: users/views.py:2
31 users/views.py:24
4
msgid "Token invalid or expired"
msgstr "Token错误或失效"
#: users/views.py:2
9
0
#: users/views.py:2
4
0
msgid "Password not same"
msgstr "密码不一致"
#, fuzzy
#~| msgid "Asset groups"
#~ msgid "Assetgroup"
#~ msgstr "用户组"
#~ msgid "Username or password invalid"
#~ msgstr "用户名或密码错误"
apps/templates/_header_bar.html
View file @
25d9dbe9
...
...
@@ -19,9 +19,15 @@
</a>
</li>
<li>
{% if user.is_authenticated %}
<a
href=
"{% url 'users:logout' %}"
>
<i
class=
"fa fa-sign-out"
></i>
Log out
<i
class=
"fa fa-sign-out"
></i>
{% trans 'Logout' %}
</a>
{% else %}
<a
href=
"{% url 'users:login' %}"
>
<i
class=
"fa fa-sign-in"
></i>
{% trans 'Login' %}
</a>
{% endif %}
</li>
</ul>
</nav>
...
...
apps/templates/_user_profile.html
View file @
25d9dbe9
...
...
@@ -8,7 +8,7 @@
<a
data-toggle=
"dropdown"
class=
"dropdown-toggle"
href=
"#"
>
<span
class=
"clear"
>
<span
class=
"block m-t-xs"
>
<strong
class=
"font-bold"
>
{{
request.
user.name }}
<span
style=
"color: #8095a8"
></span></strong>
<strong
class=
"font-bold"
>
{{ user.name }}
<span
style=
"color: #8095a8"
></span></strong>
</span>
<span
class=
"text-muted text-xs block"
>
{{ request.user.get_role_display | default:_('User') }}
<b
class=
"caret"
></b>
...
...
apps/users/forms.py
View file @
25d9dbe9
# ~*~ coding: utf-8 ~*~
from
django.forms
import
ModelForm
from
django
import
forms
from
captcha.fields
import
CaptchaField
from
django.contrib.auth.forms
import
AuthenticationForm
from
django.utils.translation
import
gettext_lazy
as
_
from
captcha.fields
import
CaptchaField
from
.models
import
User
,
UserGroup
class
UserLoginForm
(
forms
.
Form
):
class
UserLoginForm
(
Authentication
Form
):
username
=
forms
.
CharField
(
label
=
_
(
'Username'
),
max_length
=
100
)
password
=
forms
.
CharField
(
label
=
_
(
'Password'
),
widget
=
forms
.
PasswordInput
,
max_length
=
100
)
password
=
forms
.
CharField
(
label
=
_
(
'Password'
),
widget
=
forms
.
PasswordInput
,
max_length
=
100
,
strip
=
False
)
captcha
=
CaptchaField
()
class
UserCreateForm
(
ModelForm
):
class
UserCreateForm
(
forms
.
ModelForm
):
class
Meta
:
model
=
User
fields
=
[
...
...
@@ -32,7 +35,8 @@ class UserCreateForm(ModelForm):
}
class
UserUpdateForm
(
ModelForm
):
class
UserUpdateForm
(
forms
.
ModelForm
):
class
Meta
:
model
=
User
fields
=
[
...
...
@@ -47,11 +51,12 @@ class UserUpdateForm(ModelForm):
}
widgets
=
{
'groups'
:
forms
.
SelectMultiple
(
attrs
=
{
'class'
:
'select2'
,
'data-placeholder'
:
_
(
'Join usergroups'
)}),
'groups'
:
forms
.
SelectMultiple
(
attrs
=
{
'class'
:
'select2'
,
'data-placeholder'
:
_
(
'Join user
groups'
)}),
}
class
UserGroupForm
(
ModelForm
):
class
UserGroupForm
(
forms
.
ModelForm
):
class
Meta
:
model
=
UserGroup
...
...
apps/users/models.py
View file @
25d9dbe9
...
...
@@ -106,7 +106,7 @@ class User(AbstractUser):
username
=
models
.
CharField
(
max_length
=
20
,
unique
=
True
,
verbose_name
=
_
(
'Username'
))
name
=
models
.
CharField
(
max_length
=
20
,
blank
=
True
,
verbose_name
=
_
(
'Name'
))
email
=
models
.
EmailField
(
max_length
=
30
,
unique
=
True
,
verbose_name
=
_
(
'Email'
))
groups
=
models
.
ManyToManyField
(
UserGroup
,
related_name
=
'users'
,
blank
=
True
,
verbose_name
=
_
(
'Usergroup'
))
groups
=
models
.
ManyToManyField
(
UserGroup
,
related_name
=
'users'
,
blank
=
True
,
verbose_name
=
_
(
'User
group'
))
role
=
models
.
CharField
(
choices
=
ROLE_CHOICES
,
default
=
'User'
,
max_length
=
10
,
blank
=
True
,
verbose_name
=
_
(
'Role'
))
avatar
=
models
.
ImageField
(
upload_to
=
"avatar"
,
verbose_name
=
_
(
'Avatar'
))
wechat
=
models
.
CharField
(
max_length
=
30
,
blank
=
True
,
verbose_name
=
_
(
'Wechat'
))
...
...
apps/users/templates/users/_user.html
View file @
25d9dbe9
...
...
@@ -14,7 +14,7 @@
<div
class=
"col-sm-12"
>
<div
class=
"ibox float-e-margins"
>
<div
class=
"ibox-title"
>
<h5>
{%
trans 'Create user'
%}
</h5>
<h5>
{%
block user_template_title %}{% trans 'Create user' %}{% endblock
%}
</h5>
<div
class=
"ibox-tools"
>
<a
class=
"collapse-link"
>
<i
class=
"fa fa-chevron-up"
></i>
...
...
apps/users/templates/users/forg
e
t_password.html
→
apps/users/templates/users/forg
o
t_password.html
View file @
25d9dbe9
...
...
@@ -23,7 +23,7 @@
<div
class=
"ibox-content"
>
<img
src=
"{% static 'img/logo.png' %}"
style=
"margin: auto"
width=
"82"
height=
"82"
>
<h2
class=
"font-bold"
style=
"display: inline"
>
{% trans 'Forg
e
t password' %} ?
</h2>
<h2
class=
"font-bold"
style=
"display: inline"
>
{% trans 'Forg
o
t password' %} ?
</h2>
<h1></h1>
{% if errors %}
...
...
apps/users/templates/users/login.html
View file @
25d9dbe9
...
...
@@ -45,11 +45,10 @@
{% if form.errors %}
{% if 'captcha' in form.errors %}
<p
class=
"red-fonts"
>
{% trans 'Captcha invalid' %}
</p>
{% else %}
<p
class=
"red-fonts"
>
{{ form.non_field_errors.as_text }}
</p>
{% endif %}
{% endif %}
{% if errors %}
<p
class=
"red-fonts"
>
{{ errors }}
</p>
{% endif %}
<div
class=
"form-group"
>
<input
type=
"text"
class=
"form-control"
name=
"{{ form.username.html_name }}"
placeholder=
"{% trans 'Username' %}"
required=
""
>
</div>
...
...
@@ -61,8 +60,8 @@
</div>
<button
type=
"submit"
class=
"btn btn-primary block full-width m-b"
>
{% trans 'Login' %}
</button>
<a
href=
"{% url 'users:forg
e
t-password' %}"
>
<small>
Forgot password
?
</small>
<a
href=
"{% url 'users:forg
o
t-password' %}"
>
<small>
{% trans 'Forgot password' %}
?
</small>
</a>
<p
class=
"text-muted text-center"
>
...
...
@@ -84,7 +83,4 @@
</div>
</div>
</body>
</html>
apps/users/templates/users/user_detail.html
View file @
25d9dbe9
...
...
@@ -178,7 +178,7 @@
<div
class=
"panel panel-info"
>
<div
class=
"panel-heading"
>
<i
class=
"fa fa-info-circle"
></i>
{% trans 'Usergroup' %}
<i
class=
"fa fa-info-circle"
></i>
{% trans 'User
group' %}
</div>
<div
class=
"panel-body"
>
<table
class=
"table"
>
...
...
@@ -186,7 +186,7 @@
<form>
<tr>
<td
colspan=
"2"
class=
"no-borders"
>
<select
data-placeholder=
"{% trans '
Select user
groups' %}"
class=
"select2"
style=
"width: 100%"
multiple=
""
tabindex=
"4"
>
<select
data-placeholder=
"{% trans '
Join user
groups' %}"
class=
"select2"
style=
"width: 100%"
multiple=
""
tabindex=
"4"
>
{% for group in groups %}
<option
value=
"{{ group.id }}"
>
{{ group.name }}
</option>
{% endfor %}
...
...
@@ -195,7 +195,7 @@
</tr>
<tr>
<td
colspan=
"2"
class=
"no-borders"
>
<button
type=
"button"
class=
"btn btn-info btn-small"
>
{% trans '
Add
' %}
</button>
<button
type=
"button"
class=
"btn btn-info btn-small"
>
{% trans '
Join
' %}
</button>
</td>
</tr>
</form>
...
...
apps/users/templates/users/user_list.html
View file @
25d9dbe9
...
...
@@ -12,7 +12,7 @@
<th
class=
"text-center"
><a
href=
"{% url 'users:user-list' %}?sort=name"
>
{% trans 'Name' %}
</a></th>
<th
class=
"text-center"
><a
href=
"{% url 'users:user-list' %}?sort=username"
>
{% trans 'Username' %}
</a></th>
<th
class=
"text-center"
>
{% trans 'Role' %}
</th>
<th
class=
"text-center"
>
{% trans 'Usergroup' %}
</th>
<th
class=
"text-center"
>
{% trans 'User
group' %}
</th>
<th
class=
"text-center"
>
{% trans 'Asset num' %}
</th>
<th
class=
"text-center"
><a
href=
"{% url 'users:user-list' %}?sort=date_expired"
>
{% trans 'Active' %}
</a></th>
<th
class=
"text-center"
></th>
...
...
@@ -34,14 +34,14 @@
<td
class=
"text-center"
title=
"{% for user_group in user.group.all %} {{ user_group.name }} {% endfor %}"
>
{{ user.groups.all|join_queryset_attr:"name" }}
</td>
<th
class=
"text-center"
>
{{ user.name }}
</th>
<td
class=
"text-center"
>
{% if user.is_expired %}
{% if user.is_expired
and user.is_active
%}
<i
class=
"fa fa-times text-danger"
></i>
{% else %}
<i
class=
"fa fa-check text-navy"
></i>
{% endif %}
</td>
<td
class=
"text-center"
>
<a
href=
"{% url 'users:user-update' pk=user.id %}"
class=
"btn btn-xs btn-info"
>
{% trans '
Edit
' %}
</a>
<a
href=
"{% url 'users:user-update' pk=user.id %}"
class=
"btn btn-xs btn-info"
>
{% trans '
Update
' %}
</a>
<a
href=
"{% url 'users:user-delete' pk=user.id %}"
class=
"btn btn-xs btn-danger del {% if user.id == request.user.id or user.username == 'admin' %} disabled {% endif %}"
>
{% trans 'Delete' %}
</a>
</td>
</tr>
...
...
apps/users/templates/users/user_update.html
View file @
25d9dbe9
{% extends 'users/_user.html' %}
{% load i18n %}
{% block user_template_title %}{% trans "Update user" %}{% endblock %}
{% block username %}
<div
class=
"form-group"
>
<label
for=
"{{ form.username.id_for_label }}"
class=
"col-sm-2 control-label"
>
{% trans 'Username' %}
</label>
...
...
apps/users/urls.py
View file @
25d9dbe9
from
django.conf.urls
import
url
,
include
from
django.conf.urls
import
url
from
django.contrib.auth
import
views
as
auth_views
from
django.u
rls
import
reverse_lazy
from
django.u
tils.translation
import
ugettext
as
_
import
views
import
api
from
.forms
import
UserLoginForm
app_name
=
'users'
urlpatterns
=
[
url
(
r'^login$'
,
views
.
UserLoginView
.
as_view
(),
name
=
'login'
),
url
(
r'^logout$'
,
views
.
UserLogoutView
.
as_view
(),
name
=
'logout'
),
url
(
r'^password/forget$'
,
views
.
UserForgetPasswordView
.
as_view
(),
name
=
'forget-password'
),
url
(
r'^password/forget/sendmail-success$'
,
views
.
UserForgetPasswordSendmailSuccessView
.
as_view
(),
name
=
'forget-password-sendmail-success'
),
url
(
r'^login$'
,
auth_views
.
login
,
{
'template_name'
:
"users/login.html"
,
'authentication_form'
:
UserLoginForm
,
'redirect_authenticated_user'
:
True
},
name
=
'login'
),
url
(
r'^logout$'
,
auth_views
.
logout
,
{
"template_name"
:
"common/flash_message_standalone.html"
,
"extra_context"
:
{
'title'
:
_
(
'Logout success'
),
'messages'
:
_
(
'Logout success, return login page'
),
'redirect_url'
:
'/users/login'
,
'auto_redirect'
:
True
,
}
},
name
=
'logout'
),
url
(
r'^password/forgot$'
,
views
.
UserForgotPasswordView
.
as_view
(),
name
=
'forgot-password'
),
url
(
r'^password/forgot/sendmail-success$'
,
views
.
UserForgotPasswordSendmailSuccessView
.
as_view
(),
name
=
'forgot-password-sendmail-success'
),
url
(
r'^password/reset$'
,
views
.
UserResetPasswordView
.
as_view
(),
name
=
'reset-password'
),
url
(
r'^password/reset/success$'
,
views
.
UserResetPasswordSuccessView
.
as_view
(),
name
=
'reset-password-success'
),
url
(
r'^password/reset/success$'
,
views
.
UserResetPasswordSuccessView
.
as_view
(),
name
=
'reset-password-success'
),
url
(
r'^user$'
,
views
.
UserListView
.
as_view
(),
name
=
'user-list'
),
url
(
r'^user/(?P<pk>[0-9]+)$'
,
views
.
UserDetailView
.
as_view
(),
name
=
'user-detail'
),
url
(
r'^user/create$'
,
views
.
UserCreateView
.
as_view
(),
name
=
'user-create'
),
...
...
@@ -30,8 +48,10 @@ urlpatterns = [
urlpatterns
+=
[
url
(
r'^v1/users$'
,
api
.
UserListAddApi
.
as_view
(),
name
=
'user-list-api'
),
url
(
r'^v1/users/(?P<pk>[0-9]+)$'
,
api
.
UserDetailDeleteUpdateApi
.
as_view
(),
name
=
'user-detail-api'
),
url
(
r'^v1/users/(?P<pk>[0-9]+)$'
,
api
.
UserDetailDeleteUpdateApi
.
as_view
(),
name
=
'user-detail-api'
),
url
(
r'^v1/users/(?P<pk>[0-9]+)/active$'
,
api
.
UserActiveApi
.
as_view
(),
name
=
'user-active-api'
),
url
(
r'^v1/usergroups$'
,
api
.
UserGroupListAddApi
.
as_view
(),
name
=
'user-group-list-api'
),
url
(
r'^v1/usergroups/(?P<pk>[0-9]+)$'
,
api
.
UserGroupDetailDeleteUpdateApi
.
as_view
(),
name
=
'user-group-detail-api'
),
url
(
r'^v1/user-groups$'
,
api
.
UserGroupListAddApi
.
as_view
(),
name
=
'user-group-list-api'
),
url
(
r'^v1/user-groups/(?P<pk>[0-9]+)$'
,
api
.
UserGroupDetailDeleteUpdateApi
.
as_view
(),
name
=
'user-group-detail-api'
),
]
apps/users/utils.py
View file @
25d9dbe9
...
...
@@ -86,7 +86,7 @@ def user_add_success_next(user):
'name'
:
user
.
name
,
'rest_password_url'
:
reverse
(
'users:reset-password'
,
external
=
True
),
'rest_password_token'
:
user
.
generate_reset_token
(),
'forget_password_url'
:
reverse
(
'users:forg
e
t-password'
,
external
=
True
),
'forget_password_url'
:
reverse
(
'users:forg
o
t-password'
,
external
=
True
),
'email'
:
user
.
email
,
'login_url'
:
reverse
(
'users:login'
,
external
=
True
),
}
...
...
@@ -117,7 +117,7 @@ def send_reset_password_mail(user):
'name'
:
user
.
name
,
'rest_password_url'
:
reverse
(
'users:reset-password'
,
external
=
True
),
'rest_password_token'
:
user
.
generate_reset_token
(),
'forget_password_url'
:
reverse
(
'users:forg
e
t-password'
,
external
=
True
),
'forget_password_url'
:
reverse
(
'users:forg
o
t-password'
,
external
=
True
),
'email'
:
user
.
email
,
'login_url'
:
reverse
(
'users:login'
,
external
=
True
),
}
...
...
apps/users/views.py
View file @
25d9dbe9
...
...
@@ -4,78 +4,28 @@ from __future__ import unicode_literals
import
logging
from
django.shortcuts
import
get_object_or_404
,
reverse
,
render
,
Http404
,
redirect
from
django.conf
import
settings
from
django.contrib.messages.views
import
SuccessMessageMixin
from
django.db.models
import
Q
from
django.http
import
HttpResponseRedirect
from
django.shortcuts
import
get_object_or_404
,
reverse
from
django.urls
import
reverse_lazy
from
django.utils.translation
import
ugettext
as
_
from
django.db.models
import
Q
from
django.views.generic.base
import
View
,
TemplateView
from
django.views.generic.base
import
TemplateView
from
django.views.generic.list
import
ListView
from
django.views.generic.edit
import
CreateView
,
DeleteView
,
UpdateView
,
ProcessFormView
,
FormView
from
django.views.generic.edit
import
CreateView
,
DeleteView
,
UpdateView
from
django.views.generic.detail
import
DetailView
from
django.contrib.messages.views
import
SuccessMessageMixin
from
django.conf
import
settings
from
django.http
import
HttpResponseRedirect
from
django.contrib.auth
import
views
as
auth_view
,
authenticate
,
login
,
logout
from
common.utils
import
get_object_or_none
from
.models
import
User
,
UserGroup
from
.forms
import
UserCreateForm
,
UserUpdateForm
,
UserGroupForm
,
UserLoginForm
from
.utils
import
AdminUserRequiredMixin
,
ssh_key_gen
,
user_add_success_next
,
send_reset_password_mail
from
.utils
import
AdminUserRequiredMixin
,
user_add_success_next
,
send_reset_password_mail
logger
=
logging
.
getLogger
(
'jumpserver.users.views'
)
class
UserLoginView
(
FormView
):
template_name
=
'users/login.html'
form_class
=
UserLoginForm
redirect_field_name
=
'next'
def
get
(
self
,
request
,
*
args
,
**
kwargs
):
if
self
.
request
.
user
.
is_staff
:
return
redirect
(
request
.
POST
.
get
(
self
.
redirect_field_name
,
reverse
(
'index'
)))
# Todo: Django have bug, lose context issue: https://github.com/django/django/pull/7202
# so we jump it and use origin method render_to_response
# return super(UserLoginView, self).get(request, *args, **kwargs)
return
self
.
render_to_response
(
self
.
get_context_data
(
**
kwargs
))
def
post
(
self
,
request
,
*
args
,
**
kwargs
):
form
=
self
.
get_form
()
if
not
form
.
is_valid
():
return
self
.
form_invalid
(
form
)
username
=
form
[
'username'
]
.
value
()
password
=
form
[
'password'
]
.
value
()
user
=
authenticate
(
username
=
username
,
password
=
password
)
if
user
is
None
:
kwargs
.
update
({
'errors'
:
_
(
'Username or password invalid'
)})
return
self
.
get
(
request
,
*
args
,
**
kwargs
)
login
(
request
,
user
)
return
redirect
(
request
.
GET
.
get
(
self
.
redirect_field_name
,
reverse
(
'index'
)))
class
UserLogoutView
(
TemplateView
):
template_name
=
'common/flash_message_standalone.html'
def
get
(
self
,
request
,
*
args
,
**
kwargs
):
logout
(
request
)
return
super
(
UserLogoutView
,
self
)
.
get
(
request
)
def
get_context_data
(
self
,
**
kwargs
):
context
=
{
'title'
:
_
(
'Logout success'
),
'messages'
:
_
(
'Logout success, return login page'
),
'redirect_url'
:
reverse
(
'users:login'
),
'auto_redirect'
:
True
,
}
kwargs
.
update
(
context
)
return
super
(
UserLogoutView
,
self
)
.
get_context_data
(
**
kwargs
)
class
UserListView
(
AdminUserRequiredMixin
,
ListView
):
model
=
User
paginate_by
=
settings
.
CONFIG
.
DISPLAY_PER_PAGE
...
...
@@ -106,7 +56,7 @@ class UserCreateView(AdminUserRequiredMixin, SuccessMessageMixin, CreateView):
form_class
=
UserCreateForm
template_name
=
'users/user_create.html'
success_url
=
reverse_lazy
(
'users:user-list'
)
success_message
=
_
(
'Create user<a href="
%
s">
%
s</a> success.'
)
success_message
=
_
(
'Create user
<a href="
%
s">
%
s</a> success.'
)
def
get_context_data
(
self
,
**
kwargs
):
context
=
super
(
UserCreateView
,
self
)
.
get_context_data
(
**
kwargs
)
...
...
@@ -150,7 +100,7 @@ class UserUpdateView(AdminUserRequiredMixin, UpdateView):
def
get_context_data
(
self
,
**
kwargs
):
context
=
super
(
UserUpdateView
,
self
)
.
get_context_data
(
**
kwargs
)
context
.
update
({
'app'
:
_
(
'Users'
),
'action'
:
_
(
'
Edit
user'
)})
context
.
update
({
'app'
:
_
(
'Users'
),
'action'
:
_
(
'
Update
user'
)})
return
context
...
...
@@ -192,7 +142,7 @@ class UserGroupListView(AdminUserRequiredMixin, ListView):
def
get_context_data
(
self
,
**
kwargs
):
context
=
super
(
UserGroupListView
,
self
)
.
get_context_data
(
**
kwargs
)
context
.
update
({
'app'
:
_
(
'Users'
),
'action'
:
_
(
'Usergroup list'
),
'keyword'
:
self
.
keyword
})
context
.
update
({
'app'
:
_
(
'Users'
),
'action'
:
_
(
'User
group list'
),
'keyword'
:
self
.
keyword
})
return
context
...
...
@@ -230,8 +180,8 @@ class UserGroupDeleteView(DeleteView):
pass
class
UserForg
e
tPasswordView
(
TemplateView
):
template_name
=
'users/forg
e
t_password.html'
class
UserForg
o
tPasswordView
(
TemplateView
):
template_name
=
'users/forg
o
t_password.html'
def
post
(
self
,
request
,
*
args
,
**
kwargs
):
email
=
request
.
POST
.
get
(
'email'
)
...
...
@@ -240,10 +190,10 @@ class UserForgetPasswordView(TemplateView):
return
self
.
get
(
request
,
errors
=
_
(
'Email address invalid, input again'
))
else
:
send_reset_password_mail
(
user
)
return
HttpResponseRedirect
(
reverse
(
'users:forg
e
t-password-sendmail-success'
))
return
HttpResponseRedirect
(
reverse
(
'users:forg
o
t-password-sendmail-success'
))
class
UserForg
e
tPasswordSendmailSuccessView
(
TemplateView
):
class
UserForg
o
tPasswordSendmailSuccessView
(
TemplateView
):
template_name
=
'common/flash_message_standalone.html'
def
get_context_data
(
self
,
**
kwargs
):
...
...
@@ -253,7 +203,7 @@ class UserForgetPasswordSendmailSuccessView(TemplateView):
'redirect_url'
:
reverse
(
'users:login'
),
}
kwargs
.
update
(
context
)
return
super
(
UserForg
e
tPasswordSendmailSuccessView
,
self
)
.
get_context_data
(
**
kwargs
)
return
super
(
UserForg
o
tPasswordSendmailSuccessView
,
self
)
.
get_context_data
(
**
kwargs
)
class
UserResetPasswordSuccessView
(
TemplateView
):
...
...
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