mirror of https://github.com/jumpserver/jumpserver
chore: merge with dev
commit
2ab1bbaa2c
|
@ -31,7 +31,7 @@ class ApplicationAccountViewSet(JMSModelViewSet):
|
|||
permission_classes = (IsOrgAdmin, )
|
||||
search_fields = ['username', 'app_name']
|
||||
filterset_class = AccountFilterSet
|
||||
filterset_fields = ['username', 'app_name', 'app_type', 'app_category']
|
||||
filterset_fields = ['username', 'app_name', 'type', 'category']
|
||||
serializer_class = serializers.ApplicationAccountSerializer
|
||||
|
||||
http_method_names = ['get', 'put', 'patch', 'options']
|
||||
|
@ -47,10 +47,8 @@ class ApplicationAccountViewSet(JMSModelViewSet):
|
|||
.annotate(password=F('system_users__password')) \
|
||||
.annotate(app=F('applications')) \
|
||||
.annotate(app_name=F("applications__name")) \
|
||||
.annotate(app_category=F("applications__category")) \
|
||||
.annotate(app_type=F("applications__type"))\
|
||||
.values('username', 'password', 'systemuser', 'systemuser_display',
|
||||
'app', 'app_name', 'app_category', 'app_type', 'uid')
|
||||
'app', 'app_name', 'category', 'type', 'uid')
|
||||
return queryset
|
||||
|
||||
def get_object(self):
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
from collections import defaultdict
|
||||
|
||||
from django.db import models
|
||||
from django.db.models import Count
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
|
||||
from orgs.mixins.models import OrgModelMixin
|
||||
|
@ -36,6 +35,10 @@ class ApplicationTreeNodeMixin:
|
|||
'iconSkin': '',
|
||||
'meta': {
|
||||
'type': tp,
|
||||
'data': {
|
||||
'name': c.name,
|
||||
'value': c.value
|
||||
}
|
||||
}
|
||||
}
|
||||
return TreeNode(**data)
|
||||
|
|
|
@ -75,10 +75,10 @@ class ApplicationAccountSerializer(serializers.Serializer):
|
|||
app = serializers.ReadOnlyField(label=_('App'))
|
||||
uid = serializers.ReadOnlyField(label=_("Union id"))
|
||||
app_name = serializers.ReadOnlyField(label=_("Application name"), read_only=True)
|
||||
app_category = serializers.ChoiceField(label=_('Category'), choices=const.AppCategory.choices, read_only=True)
|
||||
app_category_display = serializers.SerializerMethodField(label=_('Category display'))
|
||||
app_type = serializers.ChoiceField(label=_('Type'), choices=const.AppType.choices, read_only=True)
|
||||
app_type_display = serializers.SerializerMethodField(label=_('Type display'))
|
||||
category = serializers.ChoiceField(label=_('Category'), choices=const.AppCategory.choices, read_only=True)
|
||||
category_display = serializers.SerializerMethodField(label=_('Category display'))
|
||||
type = serializers.ChoiceField(label=_('Type'), choices=const.AppType.choices, read_only=True)
|
||||
type_display = serializers.SerializerMethodField(label=_('Type display'))
|
||||
|
||||
category_mapper = dict(const.AppCategory.choices)
|
||||
type_mapper = dict(const.AppType.choices)
|
||||
|
@ -89,11 +89,11 @@ class ApplicationAccountSerializer(serializers.Serializer):
|
|||
def update(self, instance, validated_data):
|
||||
pass
|
||||
|
||||
def get_app_category_display(self, obj):
|
||||
return self.category_mapper.get(obj['app_category'])
|
||||
def get_category_display(self, obj):
|
||||
return self.category_mapper.get(obj['category'])
|
||||
|
||||
def get_app_type_display(self, obj):
|
||||
return self.type_mapper.get(obj['app_type'])
|
||||
def get_type_display(self, obj):
|
||||
return self.type_mapper.get(obj['type'])
|
||||
|
||||
|
||||
class ApplicationAccountSecretSerializer(ApplicationAccountSerializer):
|
||||
|
|
|
@ -19,7 +19,7 @@ class ApplicationPermissionViewSet(BasePermissionViewSet):
|
|||
}
|
||||
search_fields = ['name', 'category', 'type']
|
||||
custom_filter_fields = BasePermissionViewSet.custom_filter_fields + [
|
||||
'application_id', 'application'
|
||||
'application_id', 'application', 'app', 'app_name'
|
||||
]
|
||||
|
||||
def get_queryset(self):
|
||||
|
@ -29,12 +29,15 @@ class ApplicationPermissionViewSet(BasePermissionViewSet):
|
|||
return queryset
|
||||
|
||||
def filter_application(self, queryset):
|
||||
application_id = self.request.query_params.get('application_id')
|
||||
application_name = self.request.query_params.get('application')
|
||||
if application_id:
|
||||
applications = Application.objects.filter(pk=application_id)
|
||||
elif application_name:
|
||||
applications = Application.objects.filter(name=application_name)
|
||||
app_id = self.request.query_params.get('application_id') or \
|
||||
self.request.query_params.get('app')
|
||||
app_name = self.request.query_params.get('application') or \
|
||||
self.request.query_params.get('app_name')
|
||||
|
||||
if app_id:
|
||||
applications = Application.objects.filter(pk=app_id)
|
||||
elif app_name:
|
||||
applications = Application.objects.filter(name=app_name)
|
||||
else:
|
||||
return queryset
|
||||
if not applications:
|
||||
|
|
Loading…
Reference in New Issue