backported from production
This commit is contained in:
parent
e9112f8d3a
commit
6ab2823b0d
|
@ -2,10 +2,14 @@ version: "2"
|
|||
services:
|
||||
db:
|
||||
build: postgres-hstore
|
||||
restart: always
|
||||
volumes:
|
||||
- /var/spejstore-data:/var/lib/postgresql/data
|
||||
|
||||
web:
|
||||
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:
|
||||
- .:/code
|
||||
ports:
|
||||
|
|
|
@ -6,6 +6,22 @@ from storage.models import Item, Label
|
|||
from storage.serializers import ItemSerializer, LabelSerializer
|
||||
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):
|
||||
"""
|
||||
API endpoint that allows items to be viewed or edited.
|
||||
|
@ -20,6 +36,9 @@ class ItemViewSet(viewsets.ModelViewSet):
|
|||
"""
|
||||
queryset = Item.objects
|
||||
serializer_class = ItemSerializer
|
||||
filter_backends = (SmartSearchFilterBackend, filters.OrderingFilter)
|
||||
ordering_fields = '__all__'
|
||||
|
||||
|
||||
def get_queryset(self):
|
||||
return Item.get_roots()
|
||||
|
|
|
@ -28,6 +28,13 @@ class Category(models.Model):
|
|||
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):
|
||||
uuid = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False)
|
||||
|
||||
|
|
Loading…
Reference in New Issue