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
3eb4897b
Commit
3eb4897b
authored
Aug 29, 2016
by
ibuler
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'api' of code.simcu.com:jumpserver/jumpserver into api
parents
d918d5b4
3c9dbaf8
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
21 additions
and
10 deletions
+21
-10
settings.py
apps/jumpserver/settings.py
+2
-2
_user_profile.html
apps/templates/_user_profile.html
+1
-1
utils.py
apps/users/utils.py
+10
-0
views.py
apps/users/views.py
+8
-7
No files found.
apps/jumpserver/settings.py
View file @
3eb4897b
...
...
@@ -114,7 +114,7 @@ else:
'NAME'
:
CONFIG
.
DB_NAME
,
'HOST'
:
CONFIG
.
DB_HOST
,
'PORT'
:
CONFIG
.
DB_PORT
,
'USER'
:
CONFIG
.
DB_USER
NAME
,
'USER'
:
CONFIG
.
DB_USER
,
'PASSWORD'
:
CONFIG
.
DB_PASSWORD
,
}
}
...
...
@@ -263,7 +263,7 @@ WS4REDIS_CONNECTION = {
'db'
:
2
,
}
# Set the number of seconds each message shall persited
# Set the number of seconds each message shall persi
s
ted
WS4REDIS_EXPIRE
=
3600
WS4REDIS_HEARTBEAT
=
'love you'
...
...
apps/templates/_user_profile.html
View file @
3eb4897b
...
...
@@ -10,7 +10,7 @@
<strong
class=
"font-bold"
>
{{ request.user.name }}
<span
style=
"color: #8095a8"
></span></strong>
</span>
<span
class=
"text-muted text-xs block"
>
{{ r
ole
| default:'普通用户' }}
<b
class=
"caret"
></b>
{{ r
equest.user.get_role_display
| default:'普通用户' }}
<b
class=
"caret"
></b>
</span>
</span>
</a>
...
...
apps/users/utils.py
View file @
3eb4897b
# ~*~ coding: utf-8 ~*~
#
from
django.contrib.auth.mixins
import
UserPassesTestMixin
from
django.urls
import
reverse_lazy
class
AdminUserRequiredMixin
(
UserPassesTestMixin
):
login_url
=
reverse_lazy
(
'users:login'
)
def
test_func
(
self
):
return
self
.
request
.
user
.
is_staff
apps/users/views.py
View file @
3eb4897b
...
...
@@ -18,6 +18,7 @@ from django.contrib.auth import authenticate, login, logout
from
.models
import
User
,
UserGroup
from
.forms
import
UserAddForm
,
UserUpdateForm
,
UserGroupForm
,
UserLoginForm
from
.utils
import
AdminUserRequiredMixin
logger
=
logging
.
getLogger
(
'jumpserver.users.views'
)
...
...
@@ -50,7 +51,7 @@ class UserLoginView(FormView):
return
super
(
UserLoginView
,
self
)
.
form_invalid
(
form
)
class
UserListView
(
ListView
):
class
UserListView
(
AdminUserRequiredMixin
,
ListView
):
model
=
User
paginate_by
=
settings
.
CONFIG
.
DISPLAY_PER_PAGE
context_object_name
=
'user_list'
...
...
@@ -75,7 +76,7 @@ class UserListView(ListView):
return
context
class
UserAddView
(
SuccessMessageMixin
,
CreateView
):
class
UserAddView
(
AdminUserRequiredMixin
,
SuccessMessageMixin
,
CreateView
):
model
=
User
form_class
=
UserAddForm
template_name
=
'users/user_add.html'
...
...
@@ -101,7 +102,7 @@ class UserAddView(SuccessMessageMixin, CreateView):
)
class
UserUpdateView
(
UpdateView
):
class
UserUpdateView
(
AdminUserRequiredMixin
,
UpdateView
):
model
=
User
form_class
=
UserUpdateForm
template_name
=
'users/user_edit.html'
...
...
@@ -128,13 +129,13 @@ class UserUpdateView(UpdateView):
return
context
class
UserDeleteView
(
DeleteView
):
class
UserDeleteView
(
AdminUserRequiredMixin
,
DeleteView
):
model
=
User
success_url
=
reverse_lazy
(
'users:user-list'
)
template_name
=
'users/user_delete_confirm.html'
class
UserDetailView
(
DetailView
):
class
UserDetailView
(
AdminUserRequiredMixin
,
DetailView
):
model
=
User
template_name
=
'users/user_detail.html'
context_object_name
=
"user"
...
...
@@ -146,7 +147,7 @@ class UserDetailView(DetailView):
return
context
class
UserGroupListView
(
ListView
):
class
UserGroupListView
(
AdminUserRequiredMixin
,
ListView
):
model
=
UserGroup
paginate_by
=
settings
.
CONFIG
.
DISPLAY_PER_PAGE
context_object_name
=
'usergroup_list'
...
...
@@ -170,7 +171,7 @@ class UserGroupListView(ListView):
return
context
class
UserGroupAddView
(
CreateView
):
class
UserGroupAddView
(
AdminUserRequiredMixin
,
CreateView
):
model
=
UserGroup
form_class
=
UserGroupForm
template_name
=
'users/usergroup_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