summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authord42 <d42@users.noreply.github.com>2018-04-25 21:23:55 +0200
committerd42 <d42@users.noreply.github.com>2018-04-25 21:23:55 +0200
commit7e2bca899fa716990530e9601509ba4b8dc34820 (patch)
treee452fa17e0f57adba3654a8670086898252e0b25
parentf0248babe7c3bcaefa27ad4c5c75103cce268507 (diff)
downloadspejstore-7e2bca899fa716990530e9601509ba4b8dc34820.tar.gz
spejstore-7e2bca899fa716990530e9601509ba4b8dc34820.tar.bz2
spejstore-7e2bca899fa716990530e9601509ba4b8dc34820.zip
pep
-rw-r--r--storage/views.py14
1 files changed, 11 insertions, 3 deletions
diff --git a/storage/views.py b/storage/views.py
index 6ab7f8d..5c93eb6 100644
--- a/storage/views.py
+++ b/storage/views.py
@@ -1,10 +1,13 @@
+import shlex
+
from django.shortcuts import render, get_object_or_404, redirect
-from storage.models import Item, Label
from django.contrib.postgres.search import SearchVector
-from django_select2.views import AutoResponseView
from django.http import Http404, JsonResponse
from django.contrib.admin.models import LogEntry
-import shlex
+from django_select2.views import AutoResponseView
+
+from storage.models import Item, Label
+
def apply_smart_search(query, objects):
general_term = []
@@ -42,9 +45,11 @@ def apply_smart_search(query, objects):
return objects
+
def index(request):
return render(request, 'index.html')
+
def search(request):
query = request.GET.get('q', '')
@@ -58,6 +63,7 @@ def search(request):
'results': results.all(),
})
+
def item_display(request, pk):
if not pk:
return render(request, 'results.html', {
@@ -76,10 +82,12 @@ def item_display(request, pk):
'children': item.get_children().prefetch_related('categories'),
})
+
def label_lookup(request, pk):
label = get_object_or_404(Label, pk=pk)
return redirect(label.item)
+
class ItemSelectView(AutoResponseView):
def get(self, request, *args, **kwargs):
self.widget = self.get_widget_or_404()