mirror of https://github.com/jumpserver/jumpserver
fix: 修改角色列表viewset排序问题
parent
2d514c0db0
commit
c3d01591e7
|
@ -17,6 +17,7 @@ __all__ = [
|
||||||
|
|
||||||
class RoleViewSet(JMSModelViewSet):
|
class RoleViewSet(JMSModelViewSet):
|
||||||
queryset = Role.objects.all()
|
queryset = Role.objects.all()
|
||||||
|
ordering = ('-builtin', 'scope', 'name')
|
||||||
serializer_classes = {
|
serializer_classes = {
|
||||||
'default': RoleSerializer,
|
'default': RoleSerializer,
|
||||||
'users': RoleUserSerializer,
|
'users': RoleUserSerializer,
|
||||||
|
@ -61,8 +62,7 @@ class RoleViewSet(JMSModelViewSet):
|
||||||
return super().perform_update(serializer)
|
return super().perform_update(serializer)
|
||||||
|
|
||||||
def get_queryset(self):
|
def get_queryset(self):
|
||||||
queryset = super().get_queryset() \
|
queryset = super().get_queryset().annotate(permissions_amount=Count('permissions'))
|
||||||
.annotate(permissions_amount=Count('permissions'))
|
|
||||||
return queryset
|
return queryset
|
||||||
|
|
||||||
@action(methods=['GET'], detail=True)
|
@action(methods=['GET'], detail=True)
|
||||||
|
|
|
@ -43,7 +43,6 @@ class Role(JMSBaseModel):
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
unique_together = [('name', 'scope')]
|
unique_together = [('name', 'scope')]
|
||||||
ordering = ('-builtin', 'scope', 'name')
|
|
||||||
verbose_name = _('Role')
|
verbose_name = _('Role')
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
|
|
Loading…
Reference in New Issue