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