[Feature] 权限管理-> 远程应用 添加 api (#4040)

* [Feature] 权限管理-> 远程应用 添加 api

* [Feature] 添加 RelationMixin
This commit is contained in:
xinwen
2020-05-28 17:00:42 +08:00
committed by GitHub
parent 3e5d949610
commit 7dde15cb04
19 changed files with 291 additions and 45 deletions

View File

@@ -79,6 +79,23 @@ class BasePermission(OrgModelMixin):
return True
return False
@property
def all_users(self):
from users.models import User
users_query = self._meta.get_field('users').related_query_name()
user_groups_query = self._meta.get_field('user_groups').related_query_name()
users_q = Q(**{
f'{users_query}': self
})
user_groups_q = Q(**{
f'groups__{user_groups_query}': self
})
return User.objects.filter(users_q | user_groups_q).distinct()
def get_all_users(self):
from users.models import User
users_id = self.users.all().values_list('id', flat=True)