From 93575eb6c8ab3989abf1777aa1118a8ef573e5cc Mon Sep 17 00:00:00 2001 From: d0c Date: Fri, 2 Jun 2023 21:59:38 +0200 Subject: [PATCH] short view --- suitablephones/serializers.py | 2 +- suitablephones/views.py | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/suitablephones/serializers.py b/suitablephones/serializers.py index 7a64475..34aa54e 100644 --- a/suitablephones/serializers.py +++ b/suitablephones/serializers.py @@ -31,4 +31,4 @@ class DeviceSerializer(serializers.ModelSerializer): class DeviceSerializerShort(DeviceSerializer): class Meta: model = Device - fields = ["codename", "vendor", "name", "versions", "maintainers", "cameras", "screen"] \ No newline at end of file + fields = ["codename", "vendor", "name", "cameras", "screen"] \ No newline at end of file diff --git a/suitablephones/views.py b/suitablephones/views.py index 8b208e9..8481c4e 100644 --- a/suitablephones/views.py +++ b/suitablephones/views.py @@ -40,6 +40,7 @@ class DeviceViewSet(viewsets.ModelViewSet): resolution = self.request.query_params.get('resolution') screen_type = self.request.query_params.get('screen_type') soc = self.request.query_params.get('soc') + short_view = self.request.query_params.get('short_view') #maintainers = self.request.query_params.getlist('maintainers') version = self.request.query_params.get('version') if name: @@ -57,6 +58,8 @@ class DeviceViewSet(viewsets.ModelViewSet): if version: self.queryset = self.queryset.filter(versions__icontains=version) #if maintainers: + if short_view: + self.serializer_class = DeviceSerializerShort self.queryset = self.queryset.filter(maintainers__len__gt=0) return self.queryset