backported from production
This commit is contained in:
parent
e9112f8d3a
commit
6ab2823b0d
|
@ -2,10 +2,14 @@ version: "2"
|
||||||
services:
|
services:
|
||||||
db:
|
db:
|
||||||
build: postgres-hstore
|
build: postgres-hstore
|
||||||
|
restart: always
|
||||||
|
volumes:
|
||||||
|
- /var/spejstore-data:/var/lib/postgresql/data
|
||||||
|
|
||||||
web:
|
web:
|
||||||
build: .
|
build: .
|
||||||
command: wait-for-it db:5432 -- bash -c "python manage.py migrate && python manage.py runserver 0.0.0.0:8000"
|
restart: always
|
||||||
|
command: bash -c "python manage.py migrate && python manage.py runserver 0.0.0.0:8000"
|
||||||
volumes:
|
volumes:
|
||||||
- .:/code
|
- .:/code
|
||||||
ports:
|
ports:
|
||||||
|
|
|
@ -6,6 +6,22 @@ from storage.models import Item, Label
|
||||||
from storage.serializers import ItemSerializer, LabelSerializer
|
from storage.serializers import ItemSerializer, LabelSerializer
|
||||||
from django.shortcuts import get_object_or_404
|
from django.shortcuts import get_object_or_404
|
||||||
|
|
||||||
|
from storage.views import apply_smart_search
|
||||||
|
|
||||||
|
|
||||||
|
class SmartSearchFilterBackend(filters.BaseFilterBackend):
|
||||||
|
"""
|
||||||
|
Filters query using smartsearch filter
|
||||||
|
"""
|
||||||
|
|
||||||
|
def filter_queryset(self, request, queryset, view):
|
||||||
|
search_query = request.query_params.get('smartsearch', None)
|
||||||
|
if search_query:
|
||||||
|
return apply_smart_search(search_query, queryset)
|
||||||
|
|
||||||
|
return queryset
|
||||||
|
|
||||||
|
|
||||||
class LabelViewSet(viewsets.ModelViewSet):
|
class LabelViewSet(viewsets.ModelViewSet):
|
||||||
"""
|
"""
|
||||||
API endpoint that allows items to be viewed or edited.
|
API endpoint that allows items to be viewed or edited.
|
||||||
|
@ -20,6 +36,9 @@ class ItemViewSet(viewsets.ModelViewSet):
|
||||||
"""
|
"""
|
||||||
queryset = Item.objects
|
queryset = Item.objects
|
||||||
serializer_class = ItemSerializer
|
serializer_class = ItemSerializer
|
||||||
|
filter_backends = (SmartSearchFilterBackend, filters.OrderingFilter)
|
||||||
|
ordering_fields = '__all__'
|
||||||
|
|
||||||
|
|
||||||
def get_queryset(self):
|
def get_queryset(self):
|
||||||
return Item.get_roots()
|
return Item.get_roots()
|
||||||
|
|
|
@ -28,6 +28,13 @@ class Category(models.Model):
|
||||||
return self.name
|
return self.name
|
||||||
|
|
||||||
|
|
||||||
|
# TODO label versioning
|
||||||
|
# Zapisywać w URL na naklejce jej wersję, aby można było łatwo wyłapać
|
||||||
|
# przedawnione informacje
|
||||||
|
# Also przechowywać "id" z qrkodów/barkodów w historycznej bazie.
|
||||||
|
# also qrcody w stylu //s/ID (żeby się resolvowało w sieci lokalnej)
|
||||||
|
# Also ID zawierające część name
|
||||||
|
|
||||||
class Item(models.Model, TreeModelMixin):
|
class Item(models.Model, TreeModelMixin):
|
||||||
uuid = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False)
|
uuid = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue