From 0b8d97c5822dacc13c52e0c9fa94017124779fd2 Mon Sep 17 00:00:00 2001 From: d0c Date: Tue, 13 Jun 2023 16:30:18 +0200 Subject: [PATCH] vendor and release --- suitablephones/models.py | 2 +- suitablephones/views.py | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/suitablephones/models.py b/suitablephones/models.py index 2926a4b..380f268 100644 --- a/suitablephones/models.py +++ b/suitablephones/models.py @@ -61,7 +61,7 @@ class Device(models.Model): ram = models.CharField(max_length=100) recovery_boot = models.CharField(max_length=1000) recovery_reboot = models.CharField(max_length=100) - #release = models.DateField() + release = models.CharField(max_length=100, null=True) screen = models.ManyToManyField(Screen) #sdcard = models.JSONField(default=dict) # dict or str{1} soc = models.CharField(max_length=1000) diff --git a/suitablephones/views.py b/suitablephones/views.py index dc57e96..3538c97 100644 --- a/suitablephones/views.py +++ b/suitablephones/views.py @@ -36,11 +36,13 @@ class DeviceViewSet(viewsets.ModelViewSet): def get_queryset(self): name = self.request.query_params.get('name') megapixel = self.request.query_params.get('megapixel') - size_in = self.request.query_params.get('size_in') + release = self.request.query_params.get('release') resolution = self.request.query_params.get('resolution') screen_type = self.request.query_params.get('screen_type') + size_in = self.request.query_params.get('size_in') soc = self.request.query_params.get('soc') storage = self.request.query_params.get('storage') + vendor = self.request.query_params.get('vendor') version = self.request.query_params.get('version') #maintainers = self.request.query_params.getlist('maintainers') short_view = self.request.query_params.get('short_view') @@ -50,6 +52,8 @@ class DeviceViewSet(viewsets.ModelViewSet): self.queryset = self.queryset.filter(cameras__megapixel__gt=Decimal(megapixel)) if size_in: self.queryset = self.queryset.filter(screen__size_in__lt=Decimal(size_in)) + if release: + self.queryset = self.queryset.filter(release__icontains=release) if resolution: self.queryset = self.queryset.filter(screen__resolution__icontains=resolution) if screen_type: @@ -58,6 +62,8 @@ class DeviceViewSet(viewsets.ModelViewSet): self.queryset = self.queryset.filter(soc__icontains=soc) if storage: self.queryset = self.queryset.filter(storage__icontains=storage) + if vendor: + self.queryset = self.queryset.filter(vendor__icontains=vendor) if version: self.queryset = self.queryset.filter(versions__icontains=version)