mirror of https://github.com/jumpserver/jumpserver
Merge branch 'v3' of github.com:jumpserver/jumpserver into v3
commit
894f153638
|
@ -5,7 +5,3 @@ from django.utils.translation import gettext_lazy as _
|
|||
class Protocol(models.Model):
|
||||
name = models.CharField(max_length=32, verbose_name=_("Name"))
|
||||
port = models.IntegerField(verbose_name=_("Port"))
|
||||
|
||||
def save(self, force_insert=False, force_update=False, using=None,
|
||||
update_fields=None):
|
||||
pass
|
||||
|
|
|
@ -40,8 +40,7 @@ class AssetPermissionUserRelationViewSet(RelationMixin):
|
|||
|
||||
def get_queryset(self):
|
||||
queryset = super().get_queryset()
|
||||
queryset = queryset \
|
||||
.annotate(user_display=F('user__name'))
|
||||
queryset = queryset.annotate(user_display=F('user__name'))
|
||||
return queryset
|
||||
|
||||
|
||||
|
@ -69,8 +68,7 @@ class AssetPermissionUserGroupRelationViewSet(RelationMixin):
|
|||
|
||||
def get_queryset(self):
|
||||
queryset = super().get_queryset()
|
||||
queryset = queryset \
|
||||
.annotate(usergroup_display=F('usergroup__name'))
|
||||
queryset = queryset.annotate(usergroup_display=F('usergroup__name'))
|
||||
return queryset
|
||||
|
||||
|
||||
|
@ -84,8 +82,7 @@ class AssetPermissionAssetRelationViewSet(RelationMixin):
|
|||
|
||||
def get_queryset(self):
|
||||
queryset = super().get_queryset()
|
||||
queryset = queryset \
|
||||
.annotate(asset_display=F('asset__name'))
|
||||
queryset = queryset.annotate(asset_display=F('asset__name'))
|
||||
return queryset
|
||||
|
||||
|
||||
|
@ -111,7 +108,6 @@ class AssetPermissionNodeRelationViewSet(RelationMixin):
|
|||
|
||||
def get_queryset(self):
|
||||
queryset = super().get_queryset()
|
||||
queryset = queryset \
|
||||
.annotate(node_key=F('node__key'))
|
||||
queryset = queryset.annotate(node_key=F('node__key'))
|
||||
return queryset
|
||||
|
||||
|
|
|
@ -32,15 +32,15 @@ class UserDirectGrantedAssetsQuerysetMixin:
|
|||
class UserAllGrantedAssetsQuerysetMixin:
|
||||
only_fields = serializers.AssetGrantedSerializer.Meta.only_fields
|
||||
pagination_class = AllGrantedAssetPagination
|
||||
user: User
|
||||
ordering_fields = ("hostname", "ip", "port", "cpu_cores")
|
||||
ordering = ('hostname', )
|
||||
|
||||
user: User
|
||||
|
||||
def get_queryset(self):
|
||||
if getattr(self, 'swagger_fake_view', False):
|
||||
return Asset.objects.none()
|
||||
queryset = UserGrantedAssetsQueryUtils(self.user) \
|
||||
.get_all_granted_assets()
|
||||
queryset = UserGrantedAssetsQueryUtils(self.user).get_all_granted_assets()
|
||||
queryset = queryset.prefetch_related('platform').only(*self.only_fields)
|
||||
return queryset
|
||||
|
||||
|
|
|
@ -111,7 +111,7 @@ class AssetPermissionSerializer(BulkOrgResourceModelSerializer):
|
|||
# 资产
|
||||
assets_to_set = Asset.objects.filter(
|
||||
Q(ip__in=kwargs.get('assets_display')) |
|
||||
Q(hostname__in=kwargs.get('assets_display'))
|
||||
Q(name__in=kwargs.get('assets_display'))
|
||||
).distinct()
|
||||
instance.assets.add(*assets_to_set)
|
||||
# 节点
|
||||
|
|
|
@ -5,6 +5,7 @@ from rest_framework_bulk.routes import BulkRouter
|
|||
|
||||
from .. import api
|
||||
|
||||
# v3 Done
|
||||
router = BulkRouter()
|
||||
router.register('asset-permissions', api.AssetPermissionViewSet, 'asset-permission')
|
||||
router.register('asset-permissions-users-relations', api.AssetPermissionUserRelationViewSet, 'asset-permissions-users-relation')
|
||||
|
@ -86,6 +87,8 @@ user_group_permission_urlpatterns = [
|
|||
]
|
||||
|
||||
permission_urlpatterns = [
|
||||
# Todo: 获取规则中授权的所有账号列表
|
||||
#
|
||||
# 授权规则中授权的资产
|
||||
path('<uuid:pk>/assets/all/', api.AssetPermissionAllAssetListApi.as_view(), name='asset-permission-all-assets'),
|
||||
path('<uuid:pk>/users/all/', api.AssetPermissionAllUserListApi.as_view(), name='asset-permission-all-users'),
|
||||
|
|
Loading…
Reference in New Issue