From 7e2bca899fa716990530e9601509ba4b8dc34820 Mon Sep 17 00:00:00 2001 From: d42 Date: Wed, 25 Apr 2018 21:23:55 +0200 Subject: [PATCH] pep --- storage/views.py | 14 +++++++++++--- 1 file 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()