mirror of
https://github.com/i701/sarlink-portal-api.git
synced 2025-07-04 11:34:28 +00:00
Enhance DeviceListCreateAPIView to allow admin users to access all devices based on query parameter
Some checks failed
Build and Push Docker Images / Build and Push Docker Images (push) Failing after 2m37s
Some checks failed
Build and Push Docker Images / Build and Push Docker Images (push) Failing after 2m37s
This commit is contained in:
@ -30,10 +30,14 @@ class DeviceListCreateAPIView(
|
||||
|
||||
def list(self, request, *args, **kwargs):
|
||||
queryset = self.filter_queryset(self.get_queryset())
|
||||
|
||||
if request.user.is_authenticated and not getattr(
|
||||
request.user, "is_admin", False
|
||||
all_devices = request.query_params.get("all_devices", None)
|
||||
if (
|
||||
request.user.is_authenticated
|
||||
and getattr(request.user, "is_admin", False)
|
||||
and all_devices
|
||||
):
|
||||
pass
|
||||
else:
|
||||
queryset = queryset.filter(user=request.user)
|
||||
|
||||
page = self.paginate_queryset(queryset)
|
||||
|
Reference in New Issue
Block a user