diff --git a/jasset/models.py b/jasset/models.py index 746f3d109..2851b7d56 100644 --- a/jasset/models.py +++ b/jasset/models.py @@ -45,7 +45,7 @@ class IDC(models.Model): phone = models.CharField(max_length=32, blank=True, null=True, default='', verbose_name=u'联系电话') address = models.CharField(max_length=128, blank=True, null=True, default='', verbose_name=u"机房地址") network = models.TextField(blank=True, null=True, default='', verbose_name=u"IP地址段") - date_added = models.DateField(auto_now=True, default='', null=True) + date_added = models.DateField(auto_now=True, null=True) operator = models.CharField(max_length=32, blank=True, default='', null=True, verbose_name=u"运营商") comment = models.CharField(max_length=128, blank=True, default='', null=True, verbose_name=u"备注") diff --git a/jperm/ansible_api.py b/jperm/ansible_api.py index 71d6e9979..0ceea61d5 100644 --- a/jperm/ansible_api.py +++ b/jperm/ansible_api.py @@ -16,7 +16,7 @@ from passlib.hash import sha512_crypt from django.template.loader import get_template from django.template import Context -from utils import get_rand_pass + from jumpserver.api import logger diff --git a/jperm/views.py b/jperm/views.py index 09b23d37b..cb9a7d46e 100644 --- a/jperm/views.py +++ b/jperm/views.py @@ -53,21 +53,27 @@ def perm_rule_detail(request): header_title, path1, path2 = "授权规则", "规则管理", "规则详情" # 根据rule_id 取得rule对象 - rule_id = request.GET.get("id") - rule_obj = PermRule.objects.get(id=rule_id) - user_obj = rule_obj.user.all() - user_group_obj = rule_obj.user_group.all() - asset_obj = rule_obj.asset.all() - asset_group_obj = rule_obj.asset_group.all() - roles_name = [role.name for role in rule_obj.role.all()] + try: + if request.method == "GET": + rule_id = request.GET.get("id") + if not rule_id: + raise ServerError("Rule Detail - no rule id get") + rule_obj = PermRule.objects.get(id=rule_id) + user_obj = rule_obj.user.all() + user_group_obj = rule_obj.user_group.all() + asset_obj = rule_obj.asset.all() + asset_group_obj = rule_obj.asset_group.all() + roles_name = [role.name for role in rule_obj.role.all()] - # 渲染数据 - roles_name = ','.join(roles_name) - rule = rule_obj - users = user_obj - user_groups = user_group_obj - assets = asset_obj - asset_groups = asset_group_obj + # 渲染数据 + roles_name = ','.join(roles_name) + rule = rule_obj + users = user_obj + user_groups = user_group_obj + assets = asset_obj + asset_groups = asset_group_obj + except ServerError, e: + logger.warning(e) return my_render('jperm/perm_rule_detail.html', locals(), request) @@ -349,20 +355,25 @@ def perm_role_detail(request): # 渲染数据 header_title, path1, path2 = "系统用户", "系统用户管理", "系统用户详情" - if request.method == "GET": - role_id = request.GET.get("id") - role = get_object(PermRole, id=role_id) - role_info = get_role_info(role_id) + try: + if request.method == "GET": + role_id = request.GET.get("id") + if not role_id: + raise ServerError("not role id") + role = get_object(PermRole, id=role_id) + role_info = get_role_info(role_id) - # 渲染数据 - rules = role_info.get("rules") - assets = role_info.get("assets") - asset_groups = role_info.get("asset_groups") - users = role_info.get("users") - user_groups = role_info.get("user_groups") - pushed_asset, need_push_asset = get_role_push_host(get_object(PermRole, id=role_id)) + # 渲染数据 + rules = role_info.get("rules") + assets = role_info.get("assets") + asset_groups = role_info.get("asset_groups") + users = role_info.get("users") + user_groups = role_info.get("user_groups") + pushed_asset, need_push_asset = get_role_push_host(get_object(PermRole, id=role_id)) + except ServerError, e: + logger.warning(e) - return my_render('jperm/perm_role_detail.html', locals(), request) + return my_render('jperm/perm_role_detail.html', locals(), request) @require_role('admin') diff --git a/templates/jasset/idc_list.html b/templates/jasset/idc_list.html index 860f788f3..8e0fc0924 100644 --- a/templates/jasset/idc_list.html +++ b/templates/jasset/idc_list.html @@ -67,7 +67,7 @@ 编辑 - 删除 + 删除 {% endfor %} diff --git a/templates/jperm/perm_sudo_list.html b/templates/jperm/perm_sudo_list.html index cabc875b8..f69a01948 100644 --- a/templates/jperm/perm_sudo_list.html +++ b/templates/jperm/perm_sudo_list.html @@ -89,7 +89,7 @@ function remove_sudo(sudo_id){ if (confirm("确认删除")) { $.ajax({ type: "POST", - url: "/jperm/sudo/perm_sudo_delete/", + url: "/jperm/sudo/del/", data: "id=" + sudo_id, success: function(msg){ alert( "成功: " + msg );