fix: 修改角色列表viewset排序问题

pull/9414/head
Bai 2023-02-02 16:28:54 +08:00 committed by Jiangjie.Bai
parent 2d514c0db0
commit c3d01591e7
2 changed files with 2 additions and 3 deletions

View File

@ -17,6 +17,7 @@ __all__ = [
class RoleViewSet(JMSModelViewSet):
queryset = Role.objects.all()
ordering = ('-builtin', 'scope', 'name')
serializer_classes = {
'default': RoleSerializer,
'users': RoleUserSerializer,
@ -61,8 +62,7 @@ class RoleViewSet(JMSModelViewSet):
return super().perform_update(serializer)
def get_queryset(self):
queryset = super().get_queryset() \
.annotate(permissions_amount=Count('permissions'))
queryset = super().get_queryset().annotate(permissions_amount=Count('permissions'))
return queryset
@action(methods=['GET'], detail=True)

View File

@ -43,7 +43,6 @@ class Role(JMSBaseModel):
class Meta:
unique_together = [('name', 'scope')]
ordering = ('-builtin', 'scope', 'name')
verbose_name = _('Role')
def __str__(self):