Commit 3eb4897b authored by ibuler's avatar ibuler

Merge branch 'api' of code.simcu.com:jumpserver/jumpserver into api

parents d918d5b4 3c9dbaf8
......@@ -114,7 +114,7 @@ else:
'NAME': CONFIG.DB_NAME,
'HOST': CONFIG.DB_HOST,
'PORT': CONFIG.DB_PORT,
'USER': CONFIG.DB_USERNAME,
'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 persisted
WS4REDIS_EXPIRE = 3600
WS4REDIS_HEARTBEAT = 'love you'
......
......@@ -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">
{{ role | default:'普通用户' }}<b class="caret"></b>
{{ request.user.get_role_display | default:'普通用户' }}<b class="caret"></b>
</span>
</span>
</a>
......
# ~*~ 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
......@@ -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'
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment