diff --git a/jpermission/urls.py b/jpermission/urls.py index 39256ca7f..60fe5446c 100644 --- a/jpermission/urls.py +++ b/jpermission/urls.py @@ -6,7 +6,7 @@ urlpatterns = patterns('jpermission.views', # url(r'^$', 'jumpserver.views.home', name='home'), # url(r'^blog/', include('blog.urls')), - (r'^perm_user_list/$', 'perm_user_list'), + (r'^perm_host/$', 'perm_host'), (r'^perm_add/$', 'perm_add'), (r'^perm_user_show/$', 'perm_user_show'), (r'^perm_list/$', 'perm_list'), diff --git a/jpermission/views.py b/jpermission/views.py index 8da55a238..174b1f9a6 100644 --- a/jpermission/views.py +++ b/jpermission/views.py @@ -5,12 +5,23 @@ from django.http import HttpResponseRedirect from juser.models import User from jasset.models import Asset from jpermission.models import Permission - - -def perm_user_list(request): - header_title, path1, path2 = u'查看授权用户 | Perm User Detail.', u'授权管理', u'用户详情' - users = User.objects.all() - return render_to_response('jperm/perm_user_list.html', locals(),) +from django.core.paginator import Paginator, EmptyPage, InvalidPage + + +def perm_host(request): + header_title, path1, path2 = u'主机授权 | Perm Host Detail.', u'jperm', u'perm_host' + users = contact_list = User.objects.all().order_by('id') + p = paginator = Paginator(contact_list, 10) + try: + page = int(request.GET.get('page', '1')) + except ValueError: + page = 1 + + try: + contacts = paginator.page(page) + except (EmptyPage, InvalidPage): + contacts = paginator.page(paginator.num_pages) + return render_to_response('jperm/perm_host.html', locals(),) def perm_add(request): diff --git a/jumpserver/templatetags/mytags.py b/jumpserver/templatetags/mytags.py index 4c4045254..d33858277 100644 --- a/jumpserver/templatetags/mytags.py +++ b/jumpserver/templatetags/mytags.py @@ -45,4 +45,9 @@ def bool2str(value): if value: return u'是' else: - return u'否' \ No newline at end of file + return u'否' + +@register.filter(name='perm_total') +def perm_total(user_id): + user = User.objects.get(int(user_id)) + return user.permission_set.all().count() \ No newline at end of file diff --git a/templates/jperm/perm_host.html b/templates/jperm/perm_host.html new file mode 100644 index 000000000..d2f8753b0 --- /dev/null +++ b/templates/jperm/perm_host.html @@ -0,0 +1,111 @@ +{% extends 'base.html' %} +{% load mytags %} +{% block content %} +{% include 'nav_cat_bar.html' %} + +
+
+
+
+
+
主机授权 show host perm info.
+ +
+ +
+ + + + + + + + + + + + + + {% for group in contacts.object_list %} + + + + + + + + {% endfor %} + +
用户名姓名属组授权总数操作
{{ user.username }} {{ user.name }} {{ user.username|groups_str }} {{ user.id|perm_count }} + 详情 + 编辑 +
+
+
+
+ Showing {{ contacts.start_index }} to {{ contacts.end_index }} of {{ p.count }} entries +
+
+
+
+
    + {% if contacts.has_previous %} + + {% else %} + + {% endif %} + {% for page in p.page_range %} + {% ifequal offset1 page %} +
  • {{ page }}
  • + {% else %} +
  • {{ page }}
  • + {% endifequal %} + {% endfor %} + {% if contacts.has_next %} + + {% else %} + + {% endif %} +
+
+
+
+
+
+
+
+
+ + + +{% endblock %} \ No newline at end of file diff --git a/templates/jperm/perm_user_list.html b/templates/jperm/perm_user_list.html deleted file mode 100644 index 20d835726..000000000 --- a/templates/jperm/perm_user_list.html +++ /dev/null @@ -1,61 +0,0 @@ -{% extends 'base.html' %} -{% load mytags %} - -{% block content %} - {% include 'nav_cat_bar.html' %} -
-
-
-
-
-
用户信息 show user info.
- -
-
-
- - - - - - - - - {% for user in users %} - - - - - - {% endfor %} - -
ID添加授权
{{ user.id }}{{ user.username }}添加权限
-
-
- - -
-
-
-
-
-
-
-
-{% endblock %} \ No newline at end of file diff --git a/templates/nav.html b/templates/nav.html index 2eff7a7fd..451e0a097 100644 --- a/templates/nav.html +++ b/templates/nav.html @@ -34,10 +34,8 @@
  • 授权管理