mirror of https://github.com/jumpserver/jumpserver
[Bugfix] 修复校验失败api
parent
c6d50802db
commit
3039284666
|
@ -10,7 +10,7 @@ from django.forms import ModelForm
|
||||||
from django.http.response import HttpResponseForbidden
|
from django.http.response import HttpResponseForbidden
|
||||||
|
|
||||||
from common.utils import get_logger
|
from common.utils import get_logger
|
||||||
from .utils import current_org, set_current_org
|
from .utils import current_org, set_current_org, set_to_root_org
|
||||||
from .models import Organization
|
from .models import Organization
|
||||||
|
|
||||||
logger = get_logger(__file__)
|
logger = get_logger(__file__)
|
||||||
|
@ -85,6 +85,12 @@ class OrgViewGenericMixin:
|
||||||
return super().dispatch(request, *args, **kwargs)
|
return super().dispatch(request, *args, **kwargs)
|
||||||
|
|
||||||
|
|
||||||
|
class RootOrgViewMixin:
|
||||||
|
def dispatch(self, request, *args, **kwargs):
|
||||||
|
set_to_root_org()
|
||||||
|
return super().dispatch(request, *args, **kwargs)
|
||||||
|
|
||||||
|
|
||||||
class OrgModelForm(ModelForm):
|
class OrgModelForm(ModelForm):
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
super().__init__(*args, **kwargs)
|
super().__init__(*args, **kwargs)
|
||||||
|
|
|
@ -9,6 +9,7 @@ from rest_framework.pagination import LimitOffsetPagination
|
||||||
|
|
||||||
from common.utils import set_or_append_attr_bulk, get_object_or_none
|
from common.utils import set_or_append_attr_bulk, get_object_or_none
|
||||||
from common.permissions import IsValidUser, IsOrgAdmin, IsOrgAdminOrAppUser
|
from common.permissions import IsValidUser, IsOrgAdmin, IsOrgAdminOrAppUser
|
||||||
|
from orgs.mixins import RootOrgViewMixin
|
||||||
from .utils import AssetPermissionUtil
|
from .utils import AssetPermissionUtil
|
||||||
from .models import AssetPermission
|
from .models import AssetPermission
|
||||||
from .hands import AssetGrantedSerializer, User, UserGroup, Asset, Node, \
|
from .hands import AssetGrantedSerializer, User, UserGroup, Asset, Node, \
|
||||||
|
@ -236,7 +237,7 @@ class UserGroupGrantedNodeAssetsApi(ListAPIView):
|
||||||
return assets
|
return assets
|
||||||
|
|
||||||
|
|
||||||
class ValidateUserAssetPermissionView(APIView):
|
class ValidateUserAssetPermissionView(RootOrgViewMixin, APIView):
|
||||||
permission_classes = (IsOrgAdminOrAppUser,)
|
permission_classes = (IsOrgAdminOrAppUser,)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
|
|
|
@ -247,12 +247,10 @@ function initTree() {
|
||||||
value["iconSkin"] = value["is_node"] ? null : 'file';
|
value["iconSkin"] = value["is_node"] ? null : 'file';
|
||||||
});
|
});
|
||||||
zNodes = data;
|
zNodes = data;
|
||||||
{#$.fn.zTree.init($("#assetTree"), setting);#}
|
|
||||||
$.fn.zTree.init($("#assetTree"), setting, zNodes);
|
$.fn.zTree.init($("#assetTree"), setting, zNodes);
|
||||||
zTree = $.fn.zTree.getZTreeObj("assetTree");
|
zTree = $.fn.zTree.getZTreeObj("assetTree");
|
||||||
var root = zTree.getNodes()[0];
|
var root = zTree.getNodes()[0];
|
||||||
zTree.expandNode(root);
|
zTree.expandNode(root);
|
||||||
{#selectQueryNode();#}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
from __future__ import unicode_literals, absolute_import
|
from __future__ import unicode_literals, absolute_import
|
||||||
|
|
||||||
from django.utils.translation import ugettext as _
|
from django.utils.translation import ugettext as _
|
||||||
from django.views.generic import ListView, CreateView, UpdateView, DetailView
|
from django.views.generic import ListView, CreateView, UpdateView, DetailView, TemplateView
|
||||||
from django.views.generic.edit import DeleteView, SingleObjectMixin
|
from django.views.generic.edit import DeleteView, SingleObjectMixin
|
||||||
from django.urls import reverse_lazy
|
from django.urls import reverse_lazy
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
|
@ -15,11 +15,8 @@ from .models import AssetPermission
|
||||||
from .forms import AssetPermissionForm
|
from .forms import AssetPermissionForm
|
||||||
|
|
||||||
|
|
||||||
class AssetPermissionListView(AdminUserRequiredMixin, ListView):
|
class AssetPermissionListView(AdminUserRequiredMixin, TemplateView):
|
||||||
model = AssetPermission
|
|
||||||
template_name = 'perms/asset_permission_list.html'
|
template_name = 'perms/asset_permission_list.html'
|
||||||
paginate_by = settings.DISPLAY_PER_PAGE
|
|
||||||
user = user_group = asset = node = system_user = q = ""
|
|
||||||
|
|
||||||
def get_context_data(self, **kwargs):
|
def get_context_data(self, **kwargs):
|
||||||
context = {
|
context = {
|
||||||
|
|
Loading…
Reference in New Issue