# device status 页面重复设备 bug fixed
This commit is contained in:
parent
791a753162
commit
a05b4b9cb1
|
@ -15,7 +15,7 @@ from rest_framework.permissions import IsAuthenticated
|
|||
from rest_framework.filters import SearchFilter, OrderingFilter
|
||||
from mosquito.api.pagination import (
|
||||
LatestDailyPagination,
|
||||
PostPageNumberPagination,
|
||||
DeviceInfoListPagination,
|
||||
DeviceLogListPagination,
|
||||
DeviceLogHistoryPagination
|
||||
)
|
||||
|
@ -73,12 +73,12 @@ class DeviceInfoListAPIView(ListAPIView, RoleMixin):
|
|||
serializer_class = DeviceInfoSerializer
|
||||
permission_classes = [IsAuthenticated]
|
||||
filter_backends = [SearchFilter, OrderingFilter]
|
||||
pagination_class = PostPageNumberPagination
|
||||
pagination_class = DeviceInfoListPagination
|
||||
search_fields = ['device_id', 'online']
|
||||
|
||||
def get_queryset(self, *args, **kwargs):
|
||||
user_roles = self.get_role()
|
||||
queryset = DeviceInfo.objects.get_queryset().order_by('-online')
|
||||
queryset = DeviceInfo.objects.all().order_by('-last_offline_time')
|
||||
if 'staff' in user_roles or 'manager' in user_roles:
|
||||
device_ids = [query.device_id for query in queryset if query.org == self.request.user.org]
|
||||
queryset = queryset.filter(device_id__in=device_ids)
|
||||
|
|
|
@ -10,6 +10,13 @@ class PostPageNumberPagination(PageNumberPagination):
|
|||
page_size = 10
|
||||
|
||||
|
||||
class DeviceInfoListPagination(PageNumberPagination):
|
||||
page_size = 10
|
||||
page_size_query_param = 'limit'
|
||||
page_query_param = 'page'
|
||||
max_page_size = 1000
|
||||
|
||||
|
||||
class LatestDailyPagination(PageNumberPagination):
|
||||
page_size = 7
|
||||
page_size_query_param = 'limit'
|
||||
|
|
Loading…
Reference in New Issue