Commit e7d600ee authored by ibuler's avatar ibuler

Merge branch 'bugfix' of github.com:jumpserver/jumpserver into bugfix

parents b9f82fd0 186c22de
......@@ -4,7 +4,7 @@ from functools import reduce
from django.db import models
from django.utils.translation import ugettext_lazy as _
from common.utils import date_expired_default
from common.utils import date_expired_default, set_or_append_attr_bulk
from orgs.mixins import OrgModelMixin
from .base import BasePermission
......@@ -79,6 +79,14 @@ class AssetPermission(BasePermission):
def get_queryset_with_prefetch(cls):
return cls.objects.all().valid().prefetch_related('nodes', 'assets', 'system_users')
def get_all_assets(self):
assets = set(self.assets.all())
for node in self.nodes.all():
_assets = node.get_all_assets()
set_or_append_attr_bulk(_assets, 'inherit', node.value)
assets.update(set(_assets))
return assets
class NodePermission(OrgModelMixin):
id = models.UUIDField(default=uuid.uuid4, primary_key=True)
......
......@@ -155,7 +155,7 @@ class AssetPermissionAssetView(PermissionsMixin,
permission_classes = [IsOrgAdmin]
def get(self, request, *args, **kwargs):
self.object = self.get_object(queryset = AssetPermission.objects.all())
self.object = self.get_object(queryset=AssetPermission.objects.all())
return super().get(request, *args, **kwargs)
def get_queryset(self):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment