##// END OF EJS Templates
Small fixes to the websocket notifications. Make post creation atomic, not the entire view
Small fixes to the websocket notifications. Make post creation atomic, not the entire view

File last commit:

r872:752c0b44 default
r915:05c77e2a default
Show More
search.py
41 lines | 1.2 KiB | text/x-python | PythonLexer
neko259
Use own search form and view
r718 from django.shortcuts import render
from django.template import RequestContext
from django.views.generic import View
from haystack.query import SearchQuerySet
from boards.abstracts.paginator import get_paginator
from boards.forms import SearchForm, PlainErrorList
neko259
Small code cleanups
r721 FORM_QUERY = 'query'
CONTEXT_QUERY = 'query'
CONTEXT_FORM = 'form'
CONTEXT_PAGE = 'page'
REQUEST_PAGE = 'page'
neko259
Use own search form and view
r718 __author__ = 'neko259'
TEMPLATE = 'search/search.html'
class BoardSearchView(View):
def get(self, request):
context = RequestContext(request)
form = SearchForm(request.GET, error_class=PlainErrorList)
neko259
Small code cleanups
r721 context[CONTEXT_FORM] = form
neko259
Use own search form and view
r718
if form.is_valid():
neko259
Small code cleanups
r721 query = form.cleaned_data[FORM_QUERY]
neko259
Use own search form and view
r718 if len(query) >= 3:
neko259
Removed load_all from search. Fixed the debug toolbar setting to be true when debug is on
r862 results = SearchQuerySet().auto_query(query).order_by('-id')
neko259
Use own search form and view
r718 paginator = get_paginator(results, 10)
neko259
Small code cleanups
r721 if REQUEST_PAGE in request.GET:
page = int(request.GET[REQUEST_PAGE])
neko259
Use own search form and view
r718 else:
page = 1
neko259
Small code cleanups
r721 context[CONTEXT_PAGE] = paginator.page(page)
context[CONTEXT_QUERY] = query
neko259
Use own search form and view
r718
neko259
Updates to support django 1.7
r872 # TODO Use dict here
return render(request, TEMPLATE, context_instance=context)