mirror of https://github.com/jumpserver/jumpserver
修改用户组视图
parent
fd5041965b
commit
10d96a9767
|
@ -152,35 +152,35 @@ def page_list_return(total, current=1):
|
||||||
return range(min_page, max_page+1)
|
return range(min_page, max_page+1)
|
||||||
|
|
||||||
|
|
||||||
def pages(posts, r):
|
def pages(post_objects, request):
|
||||||
"""
|
"""
|
||||||
page public function , return page's object tuple
|
page public function , return page's object tuple
|
||||||
分页公用函数,返回分页的对象元组
|
分页公用函数,返回分页的对象元组
|
||||||
"""
|
"""
|
||||||
contact_list = posts
|
paginator = Paginator(post_objects, 10)
|
||||||
p = paginator = Paginator(contact_list, 10)
|
|
||||||
try:
|
try:
|
||||||
current_page = int(r.GET.get('page', '1'))
|
current_page = int(request.GET.get('page', '1'))
|
||||||
except ValueError:
|
except ValueError:
|
||||||
current_page = 1
|
current_page = 1
|
||||||
|
|
||||||
page_range = page_list_return(len(p.page_range), current_page)
|
page_range = page_list_return(len(paginator.page_range), current_page)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
contacts = paginator.page(current_page)
|
page_objects = paginator.page(current_page)
|
||||||
except (EmptyPage, InvalidPage):
|
except (EmptyPage, InvalidPage):
|
||||||
contacts = paginator.page(paginator.num_pages)
|
page_objects = paginator.page(paginator.num_pages)
|
||||||
|
|
||||||
if current_page >= 5:
|
if current_page >= 5:
|
||||||
show_first = 1
|
show_first = 1
|
||||||
else:
|
else:
|
||||||
show_first = 0
|
show_first = 0
|
||||||
if current_page <= (len(p.page_range) - 3):
|
|
||||||
|
if current_page <= (len(paginator.page_range) - 3):
|
||||||
show_end = 1
|
show_end = 1
|
||||||
else:
|
else:
|
||||||
show_end = 0
|
show_end = 0
|
||||||
|
|
||||||
return contact_list, p, contacts, page_range, current_page, show_first, show_end
|
return post_objects, paginator, page_objects, page_range, current_page, show_first, show_end
|
||||||
|
|
||||||
|
|
||||||
class Jtty(object):
|
class Jtty(object):
|
||||||
|
|
|
@ -116,10 +116,13 @@ def bool2str(value):
|
||||||
# return True
|
# return True
|
||||||
#
|
#
|
||||||
|
|
||||||
@register.filter(name='member_count')
|
@register.filter(name='members_count')
|
||||||
def member_count(group_id):
|
def members_count(group_id):
|
||||||
group = UserGroup.objects.get(id=group_id)
|
group = get_object(UserGroup, id=group_id)
|
||||||
return group.user_set.count()
|
if group:
|
||||||
|
return group.user_set.count()
|
||||||
|
else:
|
||||||
|
return 0
|
||||||
|
|
||||||
|
|
||||||
@register.filter(name='group_user_count')
|
@register.filter(name='group_user_count')
|
||||||
|
|
|
@ -13,6 +13,11 @@ class UserGroup(models.Model):
|
||||||
def get_user(self):
|
def get_user(self):
|
||||||
return self.user_set.all()
|
return self.user_set.all()
|
||||||
|
|
||||||
|
def update(self, **kwargs):
|
||||||
|
for key, value in kwargs.items():
|
||||||
|
self.__setattr__(key, value)
|
||||||
|
self.save()
|
||||||
|
|
||||||
|
|
||||||
class User(models.Model):
|
class User(models.Model):
|
||||||
USER_ROLE_CHOICES = (
|
USER_ROLE_CHOICES = (
|
||||||
|
|
|
@ -8,10 +8,9 @@ urlpatterns = patterns('juser.views',
|
||||||
# url(r'^blog/', include('blog.urls')),
|
# url(r'^blog/', include('blog.urls')),
|
||||||
|
|
||||||
(r'^group_add/$', group_add),
|
(r'^group_add/$', group_add),
|
||||||
(r'^group_list/$', view_splitter, {'su': group_list, 'adm': group_list_adm}),
|
(r'^group_list/$', group_list),
|
||||||
(r'^group_detail/$', 'group_detail'),
|
(r'^group_del/$', group_del),
|
||||||
(r'^group_del/$', view_splitter, {'su': group_del, 'adm': group_del_adm}),
|
(r'^group_del_ajax', group_del_ajax),
|
||||||
(r'^group_del_ajax/$', 'group_del_ajax'),
|
|
||||||
(r'^group_edit/$', view_splitter, {'su': group_edit, 'adm': group_edit_adm}),
|
(r'^group_edit/$', view_splitter, {'su': group_edit, 'adm': group_edit_adm}),
|
||||||
(r'^user_add/$', view_splitter, {'su': user_add, 'adm': user_add_adm}),
|
(r'^user_add/$', view_splitter, {'su': user_add, 'adm': user_add_adm}),
|
||||||
(r'^user_list/$', view_splitter, {'su': user_list, 'adm': user_list_adm}),
|
(r'^user_list/$', view_splitter, {'su': user_list, 'adm': user_list_adm}),
|
||||||
|
|
|
@ -35,6 +35,20 @@ def db_add_group(**kwargs):
|
||||||
group_add_user(group, user_id)
|
group_add_user(group, user_id)
|
||||||
|
|
||||||
|
|
||||||
|
def group_update_member(group_id, users_id_list):
|
||||||
|
"""
|
||||||
|
user group update member
|
||||||
|
用户组更新成员
|
||||||
|
"""
|
||||||
|
group = get_object(UserGroup, id=group_id)
|
||||||
|
if group:
|
||||||
|
group.user_set.clear()
|
||||||
|
for user_id in users_id_list:
|
||||||
|
user = get_object(UserGroup, id=user_id)
|
||||||
|
if isinstance(user, UserGroup):
|
||||||
|
group.user_set.add(user)
|
||||||
|
|
||||||
|
|
||||||
def db_add_user(**kwargs):
|
def db_add_user(**kwargs):
|
||||||
"""
|
"""
|
||||||
add a user in database
|
add a user in database
|
||||||
|
|
137
juser/views.py
137
juser/views.py
|
@ -24,6 +24,10 @@ def chg_role(request):
|
||||||
|
|
||||||
@require_role(role='super')
|
@require_role(role='super')
|
||||||
def group_add(request):
|
def group_add(request):
|
||||||
|
"""
|
||||||
|
group add view for route
|
||||||
|
添加用户组的视图
|
||||||
|
"""
|
||||||
error = ''
|
error = ''
|
||||||
msg = ''
|
msg = ''
|
||||||
header_title, path1, path2 = '添加用户组', '用户管理', '添加用户组'
|
header_title, path1, path2 = '添加用户组', '用户管理', '添加用户组'
|
||||||
|
@ -55,51 +59,27 @@ def group_add(request):
|
||||||
|
|
||||||
@require_role(role='super')
|
@require_role(role='super')
|
||||||
def group_list(request):
|
def group_list(request):
|
||||||
header_title, path1, path2 = '查看小组', '用户管理', '查看小组'
|
"""
|
||||||
|
list user group
|
||||||
|
用户组列表
|
||||||
|
"""
|
||||||
|
header_title, path1, path2 = '查看用户组', '用户管理', '查看用户组'
|
||||||
keyword = request.GET.get('search', '')
|
keyword = request.GET.get('search', '')
|
||||||
did = request.GET.get('did', '')
|
user_group_list = UserGroup.objects.all().order_by('name')
|
||||||
contact_list = UserGroup.objects.all().order_by('name')
|
|
||||||
|
|
||||||
if did:
|
|
||||||
dept = DEPT.objects.filter(id=did)
|
|
||||||
if dept:
|
|
||||||
dept = dept[0]
|
|
||||||
contact_list = dept.usergroup_set.all()
|
|
||||||
|
|
||||||
if keyword:
|
if keyword:
|
||||||
contact_list = contact_list.filter(Q(name__icontains=keyword) | Q(comment__icontains=keyword))
|
user_group_list = user_group_list.filter(Q(name__icontains=keyword) | Q(comment__icontains=keyword))
|
||||||
|
|
||||||
contact_list, p, contacts, page_range, current_page, show_first, show_end = pages(contact_list, request)
|
contacts, p, contacts, page_range, current_page, show_first, show_end = pages(user_group_list, request)
|
||||||
return render_to_response('juser/group_list.html', locals(), context_instance=RequestContext(request))
|
return render_to_response('juser/group_list.html', locals(), context_instance=RequestContext(request))
|
||||||
|
|
||||||
|
|
||||||
@require_role(role='admin')
|
|
||||||
def group_list_adm(request):
|
|
||||||
header_title, path1, path2 = '查看部门小组', '用户管理', '查看小组'
|
|
||||||
keyword = request.GET.get('search', '')
|
|
||||||
did = request.GET.get('did', '')
|
|
||||||
user, dept = get_session_user_dept(request)
|
|
||||||
contact_list = dept.usergroup_set.all().order_by('name')
|
|
||||||
|
|
||||||
if keyword:
|
|
||||||
contact_list = contact_list.filter(Q(name__icontains=keyword) | Q(comment__icontains=keyword))
|
|
||||||
|
|
||||||
contact_list, p, contacts, page_range, current_page, show_first, show_end = pages(contact_list, request)
|
|
||||||
return render_to_response('juser/group_list.html', locals(), context_instance=RequestContext(request))
|
|
||||||
|
|
||||||
|
|
||||||
@require_role(role='admin')
|
|
||||||
def group_detail(request):
|
|
||||||
group_id = request.GET.get('id', None)
|
|
||||||
if not group_id:
|
|
||||||
return HttpResponseRedirect('/')
|
|
||||||
group = UserGroup.objects.get(id=group_id)
|
|
||||||
users = group.user_set.all()
|
|
||||||
return render_to_response('juser/group_detail.html', locals(), context_instance=RequestContext(request))
|
|
||||||
|
|
||||||
|
|
||||||
@require_role(role='super')
|
@require_role(role='super')
|
||||||
def group_del(request):
|
def group_del(request):
|
||||||
|
"""
|
||||||
|
del a group
|
||||||
|
删除用户组
|
||||||
|
"""
|
||||||
group_id = request.GET.get('id', '')
|
group_id = request.GET.get('id', '')
|
||||||
if not group_id:
|
if not group_id:
|
||||||
return HttpResponseRedirect('/')
|
return HttpResponseRedirect('/')
|
||||||
|
@ -107,59 +87,56 @@ def group_del(request):
|
||||||
return HttpResponseRedirect('/juser/group_list/')
|
return HttpResponseRedirect('/juser/group_list/')
|
||||||
|
|
||||||
|
|
||||||
@require_role(role='admin')
|
@require_role(role='super')
|
||||||
def group_del_adm(request):
|
|
||||||
group_id = request.GET.get('id', '')
|
|
||||||
if not validate(request, user_group=[group_id]):
|
|
||||||
return HttpResponseRedirect('/juser/group_list/')
|
|
||||||
if not group_id:
|
|
||||||
return HttpResponseRedirect('/')
|
|
||||||
UserGroup.objects.filter(id=group_id).delete()
|
|
||||||
return HttpResponseRedirect('/juser/group_list/')
|
|
||||||
|
|
||||||
|
|
||||||
@require_role(role='admin')
|
|
||||||
def group_del_ajax(request):
|
def group_del_ajax(request):
|
||||||
group_ids = request.POST.get('group_ids')
|
group_ids = request.POST.get('group_ids')
|
||||||
group_ids = group_ids.split(',')
|
group_ids = group_ids.split(',')
|
||||||
if request.session.get('role_id') == 1:
|
|
||||||
if not validate(request, user_group=group_ids):
|
|
||||||
return "error"
|
|
||||||
for group_id in group_ids:
|
for group_id in group_ids:
|
||||||
UserGroup.objects.filter(id=group_id).delete()
|
UserGroup.objects.filter(id=group_id).delete()
|
||||||
return HttpResponse('删除成功')
|
return HttpResponse('删除成功')
|
||||||
|
|
||||||
|
# @require_role(role='admin')
|
||||||
|
# def group_list_adm(request):
|
||||||
|
# header_title, path1, path2 = '查看部门小组', '用户管理', '查看小组'
|
||||||
|
# keyword = request.GET.get('search', '')
|
||||||
|
# did = request.GET.get('did', '')
|
||||||
|
# user, dept = get_session_user_dept(request)
|
||||||
|
# contact_list = dept.usergroup_set.all().order_by('name')
|
||||||
|
#
|
||||||
|
# if keyword:
|
||||||
|
# contact_list = contact_list.filter(Q(name__icontains=keyword) | Q(comment__icontains=keyword))
|
||||||
|
#
|
||||||
|
# contact_list, p, contacts, page_range, current_page, show_first, show_end = pages(contact_list, request)
|
||||||
|
# return render_to_response('juser/group_list.html', locals(), context_instance=RequestContext(request))
|
||||||
|
|
||||||
def group_update_member(group_id, users_id_list):
|
#
|
||||||
group = UserGroup.objects.filter(id=group_id)
|
# @require_role(role='admin')
|
||||||
if group:
|
# def group_detail(request):
|
||||||
group = group[0]
|
# group_id = request.GET.get('id', None)
|
||||||
group.user_set.clear()
|
# if not group_id:
|
||||||
for user_id in users_id_list:
|
# return HttpResponseRedirect('/')
|
||||||
user = User.objects.get(id=user_id)
|
# group = UserGroup.objects.get(id=group_id)
|
||||||
group.user_set.add(user)
|
# users = group.user_set.all()
|
||||||
|
# return render_to_response('juser/group_detail.html', locals(), context_instance=RequestContext(request))
|
||||||
|
|
||||||
|
|
||||||
@require_role(role='super')
|
@require_role(role='super')
|
||||||
def group_edit(request):
|
def group_edit(request):
|
||||||
error = ''
|
error = ''
|
||||||
msg = ''
|
msg = ''
|
||||||
header_title, path1, path2 = '修改小组信息', '用户管理', '编辑小组'
|
header_title, path1, path2 = '编辑用户组', '用户管理', '编辑用户组'
|
||||||
|
|
||||||
if request.method == 'GET':
|
if request.method == 'GET':
|
||||||
group_id = request.GET.get('id', '')
|
group_id = request.GET.get('id', '')
|
||||||
group = UserGroup.objects.filter(id=group_id)
|
user_group = get_object(UserGroup, id=group_id)
|
||||||
if group:
|
if user_group:
|
||||||
group = group[0]
|
|
||||||
dept_all = DEPT.objects.all()
|
|
||||||
users_all = User.objects.all()
|
users_all = User.objects.all()
|
||||||
users_selected = group.user_set.all()
|
users_selected = user_group.user_set.all()
|
||||||
users = [user for user in users_all if user not in users_selected]
|
users_remain = [user for user in users_all if user not in users_selected]
|
||||||
|
|
||||||
return render_to_response('juser/group_edit.html', locals(), context_instance=RequestContext(request))
|
|
||||||
else:
|
else:
|
||||||
group_id = request.POST.get('group_id', '')
|
group_id = request.POST.get('group_id', '')
|
||||||
group_name = request.POST.get('group_name', '')
|
group_name = request.POST.get('group_name', '')
|
||||||
dept_id = request.POST.get('dept_id', '')
|
|
||||||
comment = request.POST.get('comment', '')
|
comment = request.POST.get('comment', '')
|
||||||
users_selected = request.POST.getlist('users_selected')
|
users_selected = request.POST.getlist('users_selected')
|
||||||
|
|
||||||
|
@ -167,25 +144,31 @@ def group_edit(request):
|
||||||
try:
|
try:
|
||||||
if '' in [group_id, group_name]:
|
if '' in [group_id, group_name]:
|
||||||
raise ServerError('组名不能为空')
|
raise ServerError('组名不能为空')
|
||||||
dept = DEPT.objects.filter(id=dept_id)
|
|
||||||
if dept:
|
user_group = get_object(UserGroup, id=group_id)
|
||||||
dept = dept[0]
|
other_group = get_object(UserGroup, name=group_name)
|
||||||
else:
|
|
||||||
raise ServerError('部门不存在')
|
if other_group and other_group.id != int(group_id):
|
||||||
|
raise ServerError(u'%s 用户组已存在' % group_name)
|
||||||
|
|
||||||
for user_id in users_selected:
|
for user_id in users_selected:
|
||||||
users.extend(User.objects.filter(id=user_id))
|
users.extend(User.objects.filter(id=user_id))
|
||||||
|
|
||||||
user_group = UserGroup.objects.filter(id=group_id)
|
|
||||||
if user_group:
|
if user_group:
|
||||||
user_group.update(name=group_name, comment=comment, dept=dept)
|
user_group.update(name=group_name, comment=comment)
|
||||||
user_group = user_group[0]
|
|
||||||
user_group.user_set.clear()
|
user_group.user_set.clear()
|
||||||
user_group.user_set = users
|
user_group.user_set = users
|
||||||
|
|
||||||
except ServerError, e:
|
except ServerError, e:
|
||||||
error = e
|
error = e
|
||||||
|
if not error:
|
||||||
|
return HttpResponseRedirect('/juser/group_list/')
|
||||||
|
else:
|
||||||
|
users_all = User.objects.all()
|
||||||
|
users_selected = user_group.user_set.all()
|
||||||
|
users_remain = [user for user in users_all if user not in users_selected]
|
||||||
|
|
||||||
return HttpResponseRedirect('/juser/group_list/')
|
return render_to_response('juser/group_edit.html', locals(), context_instance=RequestContext(request))
|
||||||
|
|
||||||
|
|
||||||
@require_role(role='admin')
|
@require_role(role='admin')
|
||||||
|
|
|
@ -3,6 +3,6 @@
|
||||||
Version <strong>2.0.0</strong> GPL.
|
Version <strong>2.0.0</strong> GPL.
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<strong>Copyright</strong> Jumpserver.org Organization © 2014-2015
|
<strong>Copyright</strong> Jumpserver.org Team © 2014-2015
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -20,6 +20,7 @@
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="ibox-content">
|
<div class="ibox-content">
|
||||||
<form id="groupForm" method="post" class="form-horizontal" action="">
|
<form id="groupForm" method="post" class="form-horizontal" action="">
|
||||||
{% if error %}
|
{% if error %}
|
||||||
|
@ -106,23 +107,6 @@ $('#groupForm').validator({
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
function change_type(type){
|
|
||||||
$.post('/juser/group_add_ajax/',
|
|
||||||
{'type': type},
|
|
||||||
function(data){
|
|
||||||
$('#users').html(data)
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
function change_dept(dept_id){
|
|
||||||
$.get('/juser/dept_user_ajax/',
|
|
||||||
{'id': dept_id},
|
|
||||||
function(data){
|
|
||||||
$('#users').html(data)
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
$(document).ready(function(){
|
$(document).ready(function(){
|
||||||
$("#submit_button").click(function(){
|
$("#submit_button").click(function(){
|
||||||
|
|
|
@ -1,4 +0,0 @@
|
||||||
{% for user in users %}
|
|
||||||
<option value="{{ user.id }}">{{ user.name }}</option>
|
|
||||||
{% endfor %}
|
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
{% include 'nav_cat_bar.html' %}
|
{% include 'nav_cat_bar.html' %}
|
||||||
<div class="wrapper wrapper-content animated fadeInRight">
|
<div class="wrapper wrapper-content animated fadeInRight">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-lg-10">
|
<div class="col-sm-10">
|
||||||
<div class="ibox float-e-margins">
|
<div class="ibox float-e-margins">
|
||||||
<div class="ibox-title">
|
<div class="ibox-title">
|
||||||
<h5>填写基本信息</h5>
|
<h5>填写基本信息</h5>
|
||||||
|
@ -15,12 +15,6 @@
|
||||||
<a class="dropdown-toggle" data-toggle="dropdown" href="#">
|
<a class="dropdown-toggle" data-toggle="dropdown" href="#">
|
||||||
<i class="fa fa-wrench"></i>
|
<i class="fa fa-wrench"></i>
|
||||||
</a>
|
</a>
|
||||||
<ul class="dropdown-menu dropdown-user">
|
|
||||||
<li><a href="#">未启用 1</a>
|
|
||||||
</li>
|
|
||||||
<li><a href="#">未启用 2</a>
|
|
||||||
</li>
|
|
||||||
</ul>
|
|
||||||
<a class="close-link">
|
<a class="close-link">
|
||||||
<i class="fa fa-times"></i>
|
<i class="fa fa-times"></i>
|
||||||
</a>
|
</a>
|
||||||
|
@ -35,35 +29,19 @@
|
||||||
<div class="alert alert-success text-center">{{ msg }}</div>
|
<div class="alert alert-success text-center">{{ msg }}</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="group_name" class="col-sm-2 control-label">组名<span class="red-fonts">*</span></label>
|
<label for="group_name" class="col-sm-2 control-label">用户组名<span class="red-fonts">*</span></label>
|
||||||
<div class="col-sm-8">
|
<div class="col-sm-8">
|
||||||
<input name="group_id" type="text" class="form-control" value="{{ group.id }}" style="display: none">
|
<input name="group_id" type="text" class="form-control" value="{{ user_group.id }}" style="display: none">
|
||||||
<input id="group_name" name="group_name" placeholder="Group name" type="text" class="form-control" value="{{ group.name }}">
|
<input id="group_name" name="group_name" placeholder="Group name" type="text" class="form-control" value="{{ user_group.name }}">
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{% ifequal session_role_id 2 %}
|
|
||||||
<div class="hr-line-dashed"></div>
|
<div class="hr-line-dashed"></div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="dept_id" class="col-sm-2 control-label">部门<span class="red-fonts">*</span></label>
|
<label for="users" class="col-sm-2 control-label">用户</label>
|
||||||
<div class="col-sm-8">
|
|
||||||
<select id="dept_id" name="dept_id" class="form-control m-b" onchange="change_dept(this.value)">
|
|
||||||
{% for dept in dept_all %}
|
|
||||||
{% ifequal group.dept.id dept.id %}
|
|
||||||
<option value="{{ dept.id }}" selected>{{ dept.name }}</option>
|
|
||||||
{% else %}
|
|
||||||
<option value="{{ dept.id }}">{{ dept.name }}</option>
|
|
||||||
{% endifequal %}
|
|
||||||
{% endfor %}
|
|
||||||
</select>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
{% endifequal %}
|
|
||||||
<div class="hr-line-dashed"></div>
|
|
||||||
<div class="form-group">
|
|
||||||
<label for="users" class="col-lg-2 control-label">用户</label>
|
|
||||||
<div class="col-sm-3">
|
<div class="col-sm-3">
|
||||||
<select id="users" name="users" size="12" class="form-control m-b" multiple>
|
<select id="users" name="users" size="12" class="form-control m-b" multiple>
|
||||||
{% for user in users %}
|
{% for user in users_remain %}
|
||||||
<option value="{{ user.id }}">{{ user.name }}</option>
|
<option value="{{ user.id }}">{{ user.name }}</option>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</select>
|
</select>
|
||||||
|
@ -88,7 +66,7 @@
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="comment" class="col-sm-2 control-label">备注</label>
|
<label for="comment" class="col-sm-2 control-label">备注</label>
|
||||||
<div class="col-sm-8">
|
<div class="col-sm-8">
|
||||||
<input id="comment" name="comment" placeholder="Comment" type="text" class="form-control" value="{{ group.comment }}">
|
<input id="comment" name="comment" placeholder="Comment" type="text" class="form-control" value="{{ user_group.comment }}">
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
@ -105,7 +83,9 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
|
{% block self_footer_js %}
|
||||||
<script>
|
<script>
|
||||||
$('#groupForm').validator({
|
$('#groupForm').validator({
|
||||||
timely: 2,
|
timely: 2,
|
||||||
|
@ -129,13 +109,6 @@ $('#groupForm').validator({
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
function change_type(type){
|
|
||||||
$.post('/juser/group_add_ajax/',
|
|
||||||
{'type': type},
|
|
||||||
function(data){
|
|
||||||
$('#users').html(data)
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
$(document).ready(function(){
|
$(document).ready(function(){
|
||||||
$("#submit_button").click(function(){
|
$("#submit_button").click(function(){
|
||||||
|
@ -143,18 +116,6 @@ $(document).ready(function(){
|
||||||
$(this).prop('selected', true)
|
$(this).prop('selected', true)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
})
|
});
|
||||||
|
|
||||||
function change_dept(dept_id){
|
|
||||||
$.get('/juser/dept_user_ajax/',
|
|
||||||
{'id': dept_id},
|
|
||||||
function(data){
|
|
||||||
$('#users').html(data);
|
|
||||||
$('#users_selected').html('')
|
|
||||||
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
{% endblock %}
|
{% endblock %}
|
|
@ -7,8 +7,9 @@
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-lg-10">
|
<div class="col-lg-10">
|
||||||
<div class="ibox float-e-margins">
|
<div class="ibox float-e-margins">
|
||||||
|
|
||||||
<div class="ibox-title">
|
<div class="ibox-title">
|
||||||
<h5> 查看小组</h5>
|
<h5> 查看用户组</h5>
|
||||||
<div class="ibox-tools">
|
<div class="ibox-tools">
|
||||||
<a class="collapse-link">
|
<a class="collapse-link">
|
||||||
<i class="fa fa-chevron-up"></i>
|
<i class="fa fa-chevron-up"></i>
|
||||||
|
@ -16,12 +17,6 @@
|
||||||
<a class="dropdown-toggle" data-toggle="dropdown" href="#">
|
<a class="dropdown-toggle" data-toggle="dropdown" href="#">
|
||||||
<i class="fa fa-wrench"></i>
|
<i class="fa fa-wrench"></i>
|
||||||
</a>
|
</a>
|
||||||
<ul class="dropdown-menu dropdown-user">
|
|
||||||
<li><a href="#">未启用 1</a>
|
|
||||||
</li>
|
|
||||||
<li><a href="#">未启用 2</a>
|
|
||||||
</li>
|
|
||||||
</ul>
|
|
||||||
<a class="close-link">
|
<a class="close-link">
|
||||||
<i class="fa fa-times"></i>
|
<i class="fa fa-times"></i>
|
||||||
</a>
|
</a>
|
||||||
|
@ -30,14 +25,14 @@
|
||||||
|
|
||||||
<div class="ibox-content">
|
<div class="ibox-content">
|
||||||
<div class="">
|
<div class="">
|
||||||
<a target="_blank" href="/juser/group_add/" class="btn btn-sm btn-primary "> 添加小组 </a>
|
<a target="_blank" href="/juser/group_add/" class="btn btn-sm btn-primary "> 添加用户组 </a>
|
||||||
<a id="del_btn" class="btn btn-sm btn-danger "> 删除所选 </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="" class="pull-right mail-search">
|
||||||
<div class="input-group">
|
<div class="input-group">
|
||||||
<input type="text" class="form-control input-sm" id="search_input" name="search" placeholder="Search">
|
<input type="text" class="form-control input-sm" id="search_input" name="search" placeholder="Search">
|
||||||
<div class="input-group-btn">
|
<div class="input-group-btn">
|
||||||
<button id='search_btn' type="submit" class="btn btn-sm btn-primary">
|
<button id='search_btn' type="submit" class="btn btn-sm btn-primary">
|
||||||
Search
|
—搜索—
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -51,7 +46,6 @@
|
||||||
<input type="checkbox" id="select_all" onclick="selectAll()" name="select_all">
|
<input type="checkbox" id="select_all" onclick="selectAll()" name="select_all">
|
||||||
</th>
|
</th>
|
||||||
<th class="text-center">组名</th>
|
<th class="text-center">组名</th>
|
||||||
<th class="text-center">所属部门</th>
|
|
||||||
<th class="text-center">成员数目</th>
|
<th class="text-center">成员数目</th>
|
||||||
<th class="text-center">备注</th>
|
<th class="text-center">备注</th>
|
||||||
<th class="text-center">操作</th>
|
<th class="text-center">操作</th>
|
||||||
|
@ -64,8 +58,7 @@
|
||||||
<input type="checkbox" name="selected" value="{{ group.id }}">
|
<input type="checkbox" name="selected" value="{{ group.id }}">
|
||||||
</td>
|
</td>
|
||||||
<td class="text-center"> {{ group.name }} </td>
|
<td class="text-center"> {{ group.name }} </td>
|
||||||
<td class="text-center"> {{ group.dept.name }} </td>
|
<td class="text-center"><a href="/juser/user_list/?gid={{ group.id }}"> {{ group.id | members_count }}</a> </td>
|
||||||
<td class="text-center"><a href="/juser/user_list/?gid={{ group.id }}"> {{ group.id | member_count }}</a> </td>
|
|
||||||
<td class="text-center"> {{ group.comment }} </td>
|
<td class="text-center"> {{ group.comment }} </td>
|
||||||
<td class="text-center">
|
<td class="text-center">
|
||||||
<a href="../group_edit/?id={{ group.id }}" class="btn btn-xs btn-info">编辑</a>
|
<a href="../group_edit/?id={{ group.id }}" class="btn btn-xs btn-info">编辑</a>
|
||||||
|
@ -88,25 +81,28 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
|
{% block self_footer_js %}
|
||||||
<script>
|
<script>
|
||||||
$(document).ready(function(){
|
$(document).ready(function(){
|
||||||
var check_array = []
|
var check_array = [];
|
||||||
$('#del_btn').click(function(){
|
$('#del_btn').click(function(){
|
||||||
if (confirm("确定删除")) {
|
if (confirm("确定删除")) {
|
||||||
$(".gradeX input:checked").each(function() {check_array.push($(this).attr("value")) })
|
$(".gradeX input:checked").each(function() {
|
||||||
$(".gradeX input:checked").closest("tr").remove()
|
check_array.push($(this).attr("value"))
|
||||||
|
});
|
||||||
$.post("/juser/group_del_ajax/",
|
$.post("/juser/group_del_ajax/",
|
||||||
{group_ids: check_array.join(",")},
|
{group_ids: check_array.join(",")},
|
||||||
function(data){
|
function(result){
|
||||||
|
alert(result);
|
||||||
|
$(".gradeX input:checked").closest("tr").remove();
|
||||||
|
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
{% endblock %}
|
{% endblock %}
|
Loading…
Reference in New Issue