diff --git a/jperm/models.py b/jperm/models.py
index 2232689cc..083f8089d 100644
--- a/jperm/models.py
+++ b/jperm/models.py
@@ -11,21 +11,14 @@ class Perm(models.Model):
return '%s_%s' % (self.user_group.name, self.asset_group.name)
-class CMD(models.Model):
- cmd = models.CharField(max_length=200)
-
-
class CmdGroup(models.Model):
name = models.CharField(max_length=50)
- cmd = models.ForeignKey(CMD)
+ cmd = models.CharField(max_length=999)
comment = models.CharField(blank=True, null=True, max_length=50)
class SudoPerm(models.Model):
- user = models.CharField(max_length=100)
- is_user_group = models.BooleanField(default=False)
- asset = models.CharField(max_length=100)
- is_asset_group = models.BooleanField(default=False)
- cmd = models.CharField(max_length=200)
- is_cmd_group = models.BooleanField(default=False)
-
+ user_group = models.ManyToManyField(UserGroup)
+ asset_group = models.ManyToManyField(BisGroup)
+ cmd_group = models.ManyToManyField(CmdGroup)
+ comment = models.CharField(max_length=30)
\ No newline at end of file
diff --git a/jperm/urls.py b/jperm/urls.py
index 89e6c05f1..6d34810ea 100644
--- a/jperm/urls.py
+++ b/jperm/urls.py
@@ -12,4 +12,5 @@ urlpatterns = patterns('jperm.views',
(r'^perm_detail/$', 'perm_detail'),
(r'^perm_del/$', 'perm_del'),
(r'^perm_asset_detail/$', 'perm_asset_detail'),
+ (r'^sudo_list/$', 'sudo_list'),
)
diff --git a/jperm/views.py b/jperm/views.py
index b0d18201e..ad30f23e5 100644
--- a/jperm/views.py
+++ b/jperm/views.py
@@ -4,7 +4,7 @@ from django.shortcuts import render_to_response
from django.http import HttpResponseRedirect, HttpResponse
from juser.models import User, UserGroup
from jasset.models import Asset, BisGroup
-from jperm.models import Perm
+from jperm.models import Perm, SudoPerm
from django.core.paginator import Paginator, EmptyPage, InvalidPage
@@ -137,3 +137,23 @@ def perm_asset_detail(request):
return render_to_response('jperm/perm_asset_detail.html', locals())
+def sudo_list(request):
+ header_title, path1, path2 = u'Sudo授权 | Perm Sudo Detail.', u'jperm', u'sudo_list'
+ sudo_perms = contact_list = SudoPerm.objects.all()
+ users = contact_list2 = User.objects.all().order_by('id')
+ p = paginator = Paginator(contact_list, 10)
+ p2 = paginator2 = Paginator(contact_list2, 10)
+ try:
+ page = int(request.GET.get('page', '1'))
+ except ValueError:
+ page = 1
+
+ try:
+ contacts = paginator.page(page)
+ contacts2 = paginator2.page(page)
+ except (EmptyPage, InvalidPage):
+ contacts = paginator.page(paginator.num_pages)
+ contacts2 = paginator2.page(paginator2.num_pages)
+ return render_to_response('jperm/sudo_list.html', locals())
+
+
diff --git a/templates/jperm/sudo_list.html b/templates/jperm/sudo_list.html
new file mode 100644
index 000000000..215abbe26
--- /dev/null
+++ b/templates/jperm/sudo_list.html
@@ -0,0 +1,242 @@
+{% extends 'base.html' %}
+{% load mytags %}
+{% block content %}
+{% include 'nav_cat_bar.html' %}
+
+
+
+
+
+
+
Sudo授权 show sudo perm info.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 用户(组) |
+ 主机(组) |
+ 命令(组) |
+ 操作 |
+
+
+
+ {% for sudo_perm in contacts.object_list %}
+
+
+ {% for user_group in sudo_perm.user_group %}
+ {{ user_group.name }}
+ {% endfor %}
+ |
+
+ {% for asset_group in sudo_perm.asset_group %}
+ {{ asset_group.name }}
+ {% endfor %}
+ |
+
+ {% for cmd_group in sudo_perm.cmd_group %}
+ {{ cmd_group.name }}
+ {% endfor %}
+ |
+
+ 详情
+ 编辑
+ 删除
+ |
+
+ {% endfor %}
+
+
+
+
+
+ Showing {{ contacts.start_index }} to {{ contacts.end_index }} of {{ p.count }} entries
+
+
+
+
+
+
+
+
+
+
+ 用户 |
+ 角色 |
+ 属组 |
+ 主机数量 |
+ 操作 |
+
+
+
+ {% for user in contacts2.object_list %}
+
+ {{ user.name }} |
+ {{ user.id | get_role }} |
+ {{ user.username | groups_str }} |
+ {{ user.id | perm_asset_count }} |
+
+ 详情
+ |
+
+ {% endfor %}
+
+
+
+
+
+ Showing {{ contacts2.start_index }} to {{ contacts2.end_index }} of {{ p2.count }} entries
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+{% endblock %}
\ No newline at end of file
diff --git a/templates/nav.html b/templates/nav.html
index e527f4ecf..50f71972e 100644
--- a/templates/nav.html
+++ b/templates/nav.html
@@ -33,7 +33,7 @@
授权管理