search soc

This commit is contained in:
d0c 2023-04-27 00:07:26 +02:00
parent a002819abb
commit 39144a209e
2 changed files with 6 additions and 3 deletions

View file

@ -34,7 +34,7 @@ class Screen(models.Model):
return f"{str(self.size_in)} - {str(self.density)} - {str(self.technology)}"
class Device(models.Model):
architecture = models.JSONField(default=dict)
#architecture = models.JSONField(default=dict)
#battery = models.JSONField(default=dict)
#before_install = models.JSONField(default=dict, null=True) # dict or str
bluetooth = models.ForeignKey(Bluetooth, on_delete=models.CASCADE, null=True)

View file

@ -39,20 +39,23 @@ class DeviceViewSet(viewsets.ModelViewSet):
size_in = self.request.query_params.get('size_in')
resolution = self.request.query_params.get('resolution')
screen_type = self.request.query_params.get('screen_type')
soc = self.request.query_params.get('soc')
#maintainers = self.request.query_params.getlist('maintainers')
version = self.request.query_params.get('version')
if name:
self.queryset = self.queryset.filter(name__icontains=name)
if megapixel:
self.queryset = self.queryset.filter(cameras__megapixel__gt=Decimal(megapixel))
if version:
self.queryset = self.queryset.filter(versions__icontains=version)
if size_in:
self.queryset = self.queryset.filter(screen__size_in__lt=Decimal(size_in))
if resolution:
self.queryset = self.queryset.filter(screen__resolution__icontains=resolution)
if screen_type:
self.queryset = self.queryset.filter(screen__technology__icontains=screen_type)
if soc:
self.queryset = self.queryset.filter(soc__icontains=soc)
if version:
self.queryset = self.queryset.filter(versions__icontains=version)
#if maintainers:
self.queryset = self.queryset.filter(maintainers__len__gt=0)
return self.queryset