This commit is contained in:
d0c 2023-03-30 00:22:48 +02:00
parent 386740dd9d
commit 58f19486e8
5 changed files with 15 additions and 4 deletions

View file

@ -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.
```

View file

@ -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 = [

View file

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

View file

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

View file

@ -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.