From 8f163eb634673d720b42161d0574064b21ffa8e1 Mon Sep 17 00:00:00 2001 From: guanghongwei Date: Sat, 7 Mar 2015 18:25:31 +0800 Subject: [PATCH] =?UTF-8?q?=E7=BB=9F=E4=B8=80=E5=88=86=E9=A1=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- jperm/views.py | 31 +------- templates/jperm/perm_list.html | 32 +------- templates/jperm/sudo_list.html | 135 +++++--------------------------- templates/juser/dept_list.html | 32 +------- templates/juser/group_list.html | 9 ++- templates/juser/user_list.html | 9 ++- 6 files changed, 42 insertions(+), 206 deletions(-) diff --git a/jperm/views.py b/jperm/views.py index fe7258f2b..ee91942f4 100644 --- a/jperm/views.py +++ b/jperm/views.py @@ -8,7 +8,7 @@ from jasset.models import Asset, BisGroup from jperm.models import Perm, SudoPerm, CmdGroup from django.core.paginator import Paginator, EmptyPage, InvalidPage from django.db.models import Q -from jumpserver.views import LDAP_ENABLE, ldap_conn, CONF, page_list_return +from jumpserver.views import LDAP_ENABLE, ldap_conn, CONF, page_list_return, pages from jumpserver.api import user_perm_asset_api @@ -67,18 +67,7 @@ def perm_list(request): contact_list = Perm.objects.filter(name__icontains=keyword) else: contact_list = Perm.objects.all() - p = paginator = Paginator(contact_list, 10) - try: - current_page = int(request.GET.get('page', '1')) - except ValueError: - current_page = 1 - - page_range = page_list_return(len(p.page_range), current_page) - - try: - contacts = paginator.page(current_page) - except (EmptyPage, InvalidPage): - contacts = paginator.page(paginator.num_pages) + contact_list, p, contacts, page_range, current_page, show_first, show_end = pages(contact_list, request) return render_to_response('jperm/perm_list.html', locals(), context_instance=RequestContext(request)) @@ -299,21 +288,9 @@ def sudo_add(request): def sudo_list(request): header_title, path1, path2 = u'Sudo授权', u'权限管理', u'Sudo权限详情' - sudo_perms = contact_list = SudoPerm.objects.all() - p1 = paginator1 = Paginator(contact_list, 10) - user_groups = UserGroup.objects.filter(id__gt=2) - asset_groups = BisGroup.objects.all() - cmd_groups = CmdGroup.objects.all() + contact_list = SudoPerm.objects.all() - try: - page1 = int(request.GET.get('page', '1')) - except ValueError: - page1 = 1 - - try: - contacts1 = paginator1.page(page1) - except (EmptyPage, InvalidPage): - contacts1 = paginator1.page(paginator1.num_pages) + contact_list, p, contacts, page_range, current_page, show_first, show_end = pages(contact_list, request) return render_to_response('jperm/sudo_list.html', locals(), context_instance=RequestContext(request)) diff --git a/templates/jperm/perm_list.html b/templates/jperm/perm_list.html index f3adfc82c..a58a2bfd2 100644 --- a/templates/jperm/perm_list.html +++ b/templates/jperm/perm_list.html @@ -90,37 +90,7 @@ Showing {{ contacts.start_index }} to {{ contacts.end_index }} of {{ p.count }} entries -
-
-
    - {% if contacts.has_previous %} - - {% else %} - - {% endif %} - {% for page in page_range %} - {% ifequal current_page page %} -
  • {{ page }}
  • - {% else %} -
  • {{ page }}
  • - {% endifequal %} - {% endfor %} - {% if contacts.has_next %} - - {% else %} - - {% endif %} -
-
-
+ {% include 'paginator.html' %} diff --git a/templates/jperm/sudo_list.html b/templates/jperm/sudo_list.html index fceaef4e5..debc1db81 100644 --- a/templates/jperm/sudo_list.html +++ b/templates/jperm/sudo_list.html @@ -73,27 +73,27 @@ - {% for sudo_perm in contacts1.object_list %} - - {{ sudo_perm.name }} - {{ sudo_perm.user_runas }} - - {{ sudo_perm.user_group.all | group_str2 }} - + {% for sudo_perm in contacts.object_list %} + + {{ sudo_perm.name }} + {{ sudo_perm.user_runas }} + + {{ sudo_perm.user_group.all | group_str2 }} + - - {{ sudo_perm.asset_group.all | group_str2 }} - + + {{ sudo_perm.asset_group.all | group_str2 }} + - - {{ sudo_perm.cmd_group.all | group_str2 }} - - - 详情 - 编辑 - 删除 - - + + {{ sudo_perm.cmd_group.all | group_str2 }} + + + 详情 + 编辑 + 删除 + + {% endfor %} @@ -103,106 +103,11 @@ Showing {{ contacts1.start_index }} to {{ contacts1.end_index }} of {{ p1.count }} entries -
-
-
    - {% if contacts1.has_previous %} - - {% else %} - - {% endif %} - {% for page in p1.page_range %} - {% ifequal offset1 page %} -
  • {{ page }}
  • - {% else %} -
  • {{ page }}
  • - {% endifequal %} - {% endfor %} - {% if contacts1.has_next %} - - {% else %} - - {% endif %} -
-
+ {% include 'paginator.html' %}
- -
- - - - - - - - - - - - {% for user in contacts2.object_list %} - - - - - - - - {% endfor %} - -
用户角色属组主机数量操作
{{ user.name }} {{ user.id | get_role }} {{ user.username }} {{ user.id }} - 详情 -
-
-
-
- Showing {{ contacts2.start_index }} to {{ contacts2.end_index }} of {{ p2.count }} entries -
-
-
-
-
    - {% if contacts2.has_previous %} - - {% else %} - - {% endif %} - {% for page in p2.page_range %} - {% ifequal offset1 page %} -
  • {{ page }}
  • - {% else %} -
  • {{ page }}
  • - {% endifequal %} - {% endfor %} - {% if contacts2.has_next %} - - {% else %} - - {% endif %} -
-
-
-
- -
diff --git a/templates/juser/dept_list.html b/templates/juser/dept_list.html index a8c48e2ca..5e0aedb86 100644 --- a/templates/juser/dept_list.html +++ b/templates/juser/dept_list.html @@ -80,37 +80,7 @@ Showing {{ contacts.start_index }} to {{ contacts.end_index }} of {{ p.count }} entries -
-
-
    - {% if contacts.has_previous %} - - {% else %} - - {% endif %} - {% for page in page_range %} - {% ifequal current_page page %} -
  • {{ page }}
  • - {% else %} -
  • {{ page }}
  • - {% endifequal %} - {% endfor %} - {% if contacts.has_next %} - - {% else %} - - {% endif %} -
-
-
+ {% include 'paginator.html' %} diff --git a/templates/juser/group_list.html b/templates/juser/group_list.html index 0ed29ed00..7eee5b836 100644 --- a/templates/juser/group_list.html +++ b/templates/juser/group_list.html @@ -76,7 +76,14 @@ {% endfor %} - {% include 'paginator.html' %} +
+
+
+ Showing {{ contacts.start_index }} to {{ contacts.end_index }} of {{ p.count }} entries +
+
+ {% include 'paginator.html' %} +
diff --git a/templates/juser/user_list.html b/templates/juser/user_list.html index b09f877ec..07563ac88 100644 --- a/templates/juser/user_list.html +++ b/templates/juser/user_list.html @@ -80,7 +80,14 @@ {% endfor %} - {% include 'paginator.html' %} +
+
+
+ Showing {{ contacts.start_index }} to {{ contacts.end_index }} of {{ p.count }} entries +
+
+ {% include 'paginator.html' %} +