d0c 1 year ago
parent
commit
58f19486e8

+ 8 - 1
Readme.md

@@ -21,6 +21,13 @@ git clone https://git.lattuga.net/d0c/suitablephones.git
 virtualenv .
 source bin/activate
 pip install -r requirements.txt
+```
+DB is in docker container
+```
+docker compose up -d
+```
+
+```
 python manage.py migrate
 python manage.py createsuperuser
 ```
@@ -33,7 +40,7 @@ Yaml files descripting all devices are in _"lineage_wiki/_data/devices/"_
 git clone https://github.com/LineageOS/lineage_wiki.git
 ```
 
-Set _LINEAGEWIKI_ variable in _mysuitablephone/settings.py_ with the proper path of lineage_wiki.
+Set _LINEAGEWIKI_ variable in _mysuitablephone/settings_local.py_ with the proper path of lineage_wiki.
 
 es.
 ```

+ 2 - 0
mysuitablephone/settings.py

@@ -41,6 +41,7 @@ INSTALLED_APPS = [
     'rest_framework',
     'suitablephones',
     'corsheaders',
+    'debug_toolbar',
 ]
 
 MIDDLEWARE = [
@@ -52,6 +53,7 @@ MIDDLEWARE = [
     'django.contrib.messages.middleware.MessageMiddleware',
     'django.middleware.clickjacking.XFrameOptionsMiddleware',
     'corsheaders.middleware.CorsMiddleware',
+    'debug_toolbar.middleware.DebugToolbarMiddleware',
 ]
 
 CORS_ORIGIN_WHITELIST = [

+ 1 - 0
requirements.txt

@@ -5,3 +5,4 @@ markdown
 django-filter
 psycopg2-binary
 django-cors-headers
+django-debug-toolbar

+ 1 - 0
suitablephones/management/commands/fetchphones.py

@@ -10,6 +10,7 @@ import subprocess
 import logging
 
 
+
 def update_repo():
     devicesdir = settings.LINEAGEWIKI
     pull_status = subprocess.run(["git", "pull"], cwd=devicesdir)

+ 3 - 3
suitablephones/views.py

@@ -12,9 +12,9 @@ class SingleDeviceViewSet(viewsets.ModelViewSet):
     serializer_class = DeviceSerializer
 
     def get_queryset(self):
-        codename = self.request.query_params.get('codename')
-        if codename:
-            self.queryset = self.queryset.filter(codename__icontains=codename)
+        params = self.request.query_params.get('search')
+        if params:
+            self.queryset = self.queryset.filter(codename__icontains=params) | self.queryset.filter(name__icontains=params) | self.queryset.filter(vendor__icontains=params)
         return self.queryset
 
 # ViewSets define the view behavior.