diff --git a/Readme.md b/Readme.md index a17e0b3..ec5c334 100644 --- a/Readme.md +++ b/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. ``` diff --git a/mysuitablephone/settings.py b/mysuitablephone/settings.py index 5d3fdf3..08eeba0 100644 --- a/mysuitablephone/settings.py +++ b/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 = [ diff --git a/requirements.txt b/requirements.txt index eb87fea..a12d72d 100644 --- a/requirements.txt +++ b/requirements.txt @@ -5,3 +5,4 @@ markdown django-filter psycopg2-binary django-cors-headers +django-debug-toolbar diff --git a/suitablephones/management/commands/fetchphones.py b/suitablephones/management/commands/fetchphones.py index 7b33785..dc43b2b 100644 --- a/suitablephones/management/commands/fetchphones.py +++ b/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) diff --git a/suitablephones/views.py b/suitablephones/views.py index 88d99fd..4acaae8 100644 --- a/suitablephones/views.py +++ b/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.