今天就这样了

pull/6/head
guanghongwei 10 years ago
parent 5749276812
commit b2c72221f7

@ -71,3 +71,17 @@ def require_admin(func):
return HttpResponseRedirect('/')
return func(request, *args, **kwargs)
return _deco
def is_super_user(request):
if request.session.get('role_id') == '2':
return True
else:
return False
def is_group_admin(request):
if request.session.get('role_id') == '1':
return True
else:
return False

@ -23,7 +23,8 @@ from connect import PyCrypt, KEY
from connect import BASE_DIR
from connect import CONF
from jumpserver.views import md5_crypt, LDAPMgmt, LDAP_ENABLE, ldap_conn, page_list_return, pages
from jumpserver.api import user_perm_group_api, require_login, require_super_user, require_admin
from jumpserver.api import user_perm_group_api, require_login, require_super_user, \
require_admin, is_group_admin, is_super_user
if LDAP_ENABLE:
LDAP_HOST_URL = CONF.get('ldap', 'host_url')
@ -369,10 +370,21 @@ def group_add(request):
def group_list(request):
header_title, path1, path2 = '鏌ョ湅灏忕粍', '鐢ㄦ埛绠$悊', '鏌ョ湅灏忕粍'
keyword = request.GET.get('search', '')
contact_list = []
if is_super_user(request):
if keyword:
contact_list = UserGroup.objects.filter(Q(name__icontains=keyword) | Q(comment__icontains=keyword))
else:
contact_list = UserGroup.objects.all().order_by('name')
elif is_group_admin(request):
user_id = request.session.get('user_id', '')
user = User.objects.filter(id=user_id)
if user:
user = user[0]
if keyword:
contact_list = UserGroup.objects.filter(Q(dept=user.dept) & Q(name__icontains=keyword) | Q(comment__icontains=keyword))
else:
contact_list = UserGroup.objects.filter(dept=user.dept).order_by('name')
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))

@ -1,3 +1,4 @@
{% ifequal session_role_id 2 %}
<nav class="navbar-default navbar-static-side" role="navigation">
<div class="sidebar-collapse">
<ul class="nav" id="side-menu">
@ -71,3 +72,72 @@
</div>
</nav>
{% endifequal %}
{% ifequal session_role_id 1 %}
<nav class="navbar-default navbar-static-side" role="navigation">
<div class="sidebar-collapse">
<ul class="nav" id="side-menu">
{% include 'nav_li_profile.html' %}
<li>
<a href="/"><i class="fa fa-th-large"></i> <span class="nav-label">浠〃鐩</span><span class="label label-info pull-right"></span></a>
<!--<a href="index.html"><i class="fa fa-th-large"></i> <span class="nav-label">浠〃鐩</span> <span class="fa arrow"></span></a>
<ul class="nav nav-second-level">
<li><a href="index.html">Dashboard v.1</a></li>
<li ><a href="dashboard_2.html">Dashboard v.2</a></li>
<li ><a href="dashboard_3.html">Dashboard v.3</a></li>
</ul>-->
</li>
<li id="juser">
<a href="#"><i class="fa fa-rebel"></i> <span class="nav-label">鐢ㄦ埛绠$悊</span><span class="fa arrow"></span></a>
<ul class="nav nav-second-level">
<li id="group_list"><a href="/juser/group_list/">鏌ョ湅灏忕粍</a></li>
<li id="group_add"><a href="/juser/group_add/">娣诲姞灏忕粍</a></li>
<li id="user_list"><a href="/juser/user_list/">鏌ョ湅鐢ㄦ埛<span class="label {% ifequal user_active_num user_total_num %}label-primary {% else %}label-warning {% endifequal %}pull-right">{{ user_active_num }}/{{ user_total_num }}</span></a></li>
<li id="user_add"><a href="/juser/user_add/">娣诲姞鐢ㄦ埛</a></li>
</ul>
</li>
<li id="jasset">
<a><i class="fa fa-cube"></i> <span class="nav-label">璧勪骇绠$悊</span><span class="fa arrow"></span></a>
<ul class="nav nav-second-level">
<li id="host_add"><a href="/jasset/host_add/">娣诲姞璧勪骇</a></li>
<li id="host_list"><a href="/jasset/host_list/">鏌ョ湅璧勪骇&nbsp&nbsp</span><span class="label label-info pull-right">16/18</span></a></li>
<li id="jgroup_add"><a href="/jasset/jgroup_add/">娣诲姞涓绘満缁</a></li>
<li id="jgroup_list"><a href="/jasset/jgroup_list/">鏌ョ湅涓绘満缁</a></li>
<li id="idc_add"><a href="/jasset/idc_add/">娣诲姞IDC</a></li>
<li id="idc_list"><a href="/jasset/idc_list/">鏌ョ湅IDC</a></li>
</ul>
</li>
<li id="jperm">
<a href="#"><i class="fa fa-edit"></i> <span class="nav-label">鎺堟潈绠$悊</span><span class="fa arrow"></span></a>
<ul class="nav nav-second-level">
<li id="perm_list">
<a href="/jperm/perm_list/">灏忕粍鎺堟潈</a>
</li>
<li id="sudo_add">
<a href="/jperm/sudo_list/">Sudo鎺堟潈</a>
</li>
</ul>
</li>
<li id="jlog">
<a href="#"><i class="fa fa-files-o"></i> <span class="nav-label">鏃ュ織瀹¤</span><span class="fa arrow"></span></a>
<ul class="nav nav-second-level">
<li id="log_list"><a href="/jlog/log_list/online/">鏌ョ湅鏃ュ織</a></li>
<li id="log_detail"><a href="/jlog/log_detail/">鏃ュ織鍒嗘瀽</a></li>
</ul>
</li>
<li>
<a href="#"><i class="fa fa-download"></i> <span class="nav-label">涓婁紶涓嬭浇</span><span class="fa arrow"></span></a>
<ul class="nav nav-second-level">
<li><a href="/file/upload/">鏂囦欢涓婁紶</a></li>
<li><a href="/file/download/">鏂囦欢涓嬭浇</a></li>
</ul>
</li>
<li class="special_link">
<a href="http://www.jumpserver.org" target="_blank"><i class="fa fa-database"></i> <span class="nav-label">璁块棶瀹樼綉</span></a>
</li>
</ul>
</div>
</nav>
{% endifequal %}
Loading鈥
Cancel
Save