From 84610f2a2c753e50e9c6e2bd7a7697db54c10ba0 Mon Sep 17 00:00:00 2001 From: BaiJiangJie <32935519+BaiJiangJie@users.noreply.github.com> Date: Tue, 21 May 2019 17:01:47 +0800 Subject: [PATCH] =?UTF-8?q?[Bugfix]=20=E4=BF=AE=E6=94=B9PermsModel?= =?UTF-8?q?=E6=8A=BD=E8=B1=A1=E5=90=8E=E7=9A=84objects-bug=20(#2713)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * [Bugfix] 修改PermsModel抽象后的objects-bug * [Bugfix] 删除无用代码 --- apps/perms/models/asset_permission.py | 2 +- apps/perms/models/base.py | 3 ++- apps/perms/models/remote_app_permission.py | 4 +--- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/apps/perms/models/asset_permission.py b/apps/perms/models/asset_permission.py index 9091ce3f0..ed0aaa535 100644 --- a/apps/perms/models/asset_permission.py +++ b/apps/perms/models/asset_permission.py @@ -33,7 +33,7 @@ class Action(models.Model): return cls.objects.get(name=PERMS_ACTION_NAME_ALL) -class AssetPermission(OrgModelMixin, BasePermission): +class AssetPermission(BasePermission): assets = models.ManyToManyField('assets.Asset', related_name='granted_by_permissions', blank=True, verbose_name=_("Asset")) nodes = models.ManyToManyField('assets.Node', related_name='granted_by_permissions', blank=True, verbose_name=_("Nodes")) system_users = models.ManyToManyField('assets.SystemUser', related_name='granted_by_permissions', verbose_name=_("System user")) diff --git a/apps/perms/models/base.py b/apps/perms/models/base.py index 4665bcd2a..345ebd4e8 100644 --- a/apps/perms/models/base.py +++ b/apps/perms/models/base.py @@ -5,6 +5,7 @@ import uuid from django.utils.translation import ugettext_lazy as _ from django.db import models from django.utils import timezone +from orgs.mixins import OrgModelMixin from common.utils import date_expired_default, set_or_append_attr_bulk from orgs.mixins import OrgManager @@ -29,7 +30,7 @@ class BasePermissionManager(OrgManager): return self.get_queryset().valid() -class BasePermission(models.Model): +class BasePermission(OrgModelMixin): id = models.UUIDField(default=uuid.uuid4, primary_key=True) name = models.CharField(max_length=128, verbose_name=_('Name')) users = models.ManyToManyField('users.User', blank=True, verbose_name=_("User")) diff --git a/apps/perms/models/remote_app_permission.py b/apps/perms/models/remote_app_permission.py index b705a2ab3..706467396 100644 --- a/apps/perms/models/remote_app_permission.py +++ b/apps/perms/models/remote_app_permission.py @@ -4,8 +4,6 @@ from django.db import models from django.utils.translation import ugettext_lazy as _ -from orgs.mixins import OrgModelMixin - from .base import BasePermission __all__ = [ @@ -13,7 +11,7 @@ __all__ = [ ] -class RemoteAppPermission(OrgModelMixin, BasePermission): +class RemoteAppPermission(BasePermission): remote_apps = models.ManyToManyField('applications.RemoteApp', related_name='granted_by_permissions', blank=True, verbose_name=_("RemoteApp")) class Meta: