|
|
@ -52,20 +52,21 @@ class AccountViewSet(OrgBulkModelViewSet):
|
|
|
|
return Response(data=serializer.data)
|
|
|
|
return Response(data=serializer.data)
|
|
|
|
|
|
|
|
|
|
|
|
@action(
|
|
|
|
@action(
|
|
|
|
methods=['get'], detail=False, url_path='username-suggestions',
|
|
|
|
methods=['post'], detail=False, url_path='username-suggestions',
|
|
|
|
permission_classes=[IsValidUser]
|
|
|
|
permission_classes=[IsValidUser]
|
|
|
|
)
|
|
|
|
)
|
|
|
|
def username_suggestions(self, request, *args, **kwargs):
|
|
|
|
def username_suggestions(self, request, *args, **kwargs):
|
|
|
|
asset_ids = request.query_params.get('assets')
|
|
|
|
asset_ids = request.data.get('assets')
|
|
|
|
node_keys = request.query_params.get('keys')
|
|
|
|
node_ids = request.data.get('nodes')
|
|
|
|
username = request.query_params.get('username')
|
|
|
|
username = request.data.get('username')
|
|
|
|
|
|
|
|
|
|
|
|
assets = Asset.objects.all()
|
|
|
|
assets = Asset.objects.all()
|
|
|
|
if asset_ids:
|
|
|
|
if asset_ids:
|
|
|
|
assets = assets.filter(id__in=asset_ids.split(','))
|
|
|
|
assets = assets.filter(id__in=asset_ids)
|
|
|
|
if node_keys:
|
|
|
|
if node_ids:
|
|
|
|
patten = Node.get_node_all_children_key_pattern(node_keys.split(','))
|
|
|
|
nodes = Node.objects.filter(id__in=node_ids)
|
|
|
|
assets = assets.filter(nodes__key__regex=patten)
|
|
|
|
node_asset_ids = Node.get_nodes_all_assets(*nodes).values_list('id', flat=True)
|
|
|
|
|
|
|
|
assets = assets.filter(id__in=set(list(asset_ids) + list(node_asset_ids)))
|
|
|
|
|
|
|
|
|
|
|
|
accounts = Account.objects.filter(asset__in=assets)
|
|
|
|
accounts = Account.objects.filter(asset__in=assets)
|
|
|
|
if username:
|
|
|
|
if username:
|
|
|
|