[Update] 修改remote app api

This commit is contained in:
ibuler
2020-05-09 14:51:19 +08:00
parent 8c0bf0b71b
commit 0a7f63cc5e
7 changed files with 62 additions and 50 deletions

View File

@@ -3,9 +3,9 @@ import logging
from functools import reduce
from django.db import models
from django.db.models import Q
from django.utils.translation import ugettext_lazy as _
from common.utils import lazyproperty
from orgs.models import Organization
from orgs.utils import get_current_org
from assets.models import Asset, SystemUser, Node
@@ -87,6 +87,18 @@ class AssetPermission(BasePermission):
verbose_name = _("Asset permission")
ordering = ('name',)
@lazyproperty
def assets_amount(self):
return self.assets.count()
@lazyproperty
def nodes_amount(self):
return self.nodes.count()
@lazyproperty
def system_users_amount(self):
return self.system_users.count()
@classmethod
def get_queryset_with_prefetch(cls):
return cls.objects.all().valid().prefetch_related(