##// END OF EJS Templates
Moved signatures block to the model block. All the signed content is in the 'content' block now. Removed edit time, previous and next posts links from the XML sync output because they can be computed from the post itself and can be changed locally for foreign posts (which breaks the signature)
Moved signatures block to the model block. All the signed content is in the 'content' block now. Removed edit time, previous and next posts links from the XML sync output because they can be computed from the post itself and can be changed locally for foreign posts (which breaks the signature)

File last commit:

r749:f14417a3 default
r838:2b96b9e7 decentral
Show More
search.py
40 lines | 1.2 KiB | text/x-python | PythonLexer
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
FORM_QUERY = 'query'
CONTEXT_QUERY = 'query'
CONTEXT_FORM = 'form'
CONTEXT_PAGE = 'page'
REQUEST_PAGE = 'page'
__author__ = 'neko259'
TEMPLATE = 'search/search.html'
class BoardSearchView(View):
def get(self, request):
context = RequestContext(request)
form = SearchForm(request.GET, error_class=PlainErrorList)
context[CONTEXT_FORM] = form
if form.is_valid():
query = form.cleaned_data[FORM_QUERY]
if len(query) >= 3:
results = SearchQuerySet().auto_query(query).order_by('-id').load_all()
paginator = get_paginator(results, 10)
if REQUEST_PAGE in request.GET:
page = int(request.GET[REQUEST_PAGE])
else:
page = 1
context[CONTEXT_PAGE] = paginator.page(page)
context[CONTEXT_QUERY] = query
return render(request, TEMPLATE, context)