mirror of
https://github.com/i701/sarlink-portal-api.git
synced 2025-07-03 22:08:22 +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):
|
def list(self, request, *args, **kwargs):
|
||||||
queryset = self.filter_queryset(self.get_queryset())
|
queryset = self.filter_queryset(self.get_queryset())
|
||||||
|
all_devices = request.query_params.get("all_devices", None)
|
||||||
if request.user.is_authenticated and not getattr(
|
if (
|
||||||
request.user, "is_admin", False
|
request.user.is_authenticated
|
||||||
|
and getattr(request.user, "is_admin", False)
|
||||||
|
and all_devices
|
||||||
):
|
):
|
||||||
|
pass
|
||||||
|
else:
|
||||||
queryset = queryset.filter(user=request.user)
|
queryset = queryset.filter(user=request.user)
|
||||||
|
|
||||||
page = self.paginate_queryset(queryset)
|
page = self.paginate_queryset(queryset)
|
||||||
|
Reference in New Issue
Block a user