src/p4l/search/views.py
author ymh <ymh.work@gmail.com>
Sat, 28 Sep 2013 02:55:26 +0200
changeset 120 6ec0300b626e
parent 117 0a4e7d6ebe80
child 126 a345f1a67bf1
permissions -rw-r--r--
- update django - clear search input - footer
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
113
c05567404888 First version of indexation. Replace the list view by a search view
ymh <ymh.work@gmail.com>
parents:
diff changeset
     1
# -*- coding: utf-8 -*-
c05567404888 First version of indexation. Replace the list view by a search view
ymh <ymh.work@gmail.com>
parents:
diff changeset
     2
'''
c05567404888 First version of indexation. Replace the list view by a search view
ymh <ymh.work@gmail.com>
parents:
diff changeset
     3
Created on Sep 20, 2013
c05567404888 First version of indexation. Replace the list view by a search view
ymh <ymh.work@gmail.com>
parents:
diff changeset
     4
c05567404888 First version of indexation. Replace the list view by a search view
ymh <ymh.work@gmail.com>
parents:
diff changeset
     5
@author: ymh
c05567404888 First version of indexation. Replace the list view by a search view
ymh <ymh.work@gmail.com>
parents:
diff changeset
     6
'''
c05567404888 First version of indexation. Replace the list view by a search view
ymh <ymh.work@gmail.com>
parents:
diff changeset
     7
from django.conf import settings
c05567404888 First version of indexation. Replace the list view by a search view
ymh <ymh.work@gmail.com>
parents:
diff changeset
     8
from django.template.context import RequestContext
c05567404888 First version of indexation. Replace the list view by a search view
ymh <ymh.work@gmail.com>
parents:
diff changeset
     9
from haystack.query import SearchQuerySet
c05567404888 First version of indexation. Replace the list view by a search view
ymh <ymh.work@gmail.com>
parents:
diff changeset
    10
from haystack.views import SearchView, search_view_factory
c05567404888 First version of indexation. Replace the list view by a search view
ymh <ymh.work@gmail.com>
parents:
diff changeset
    11
c05567404888 First version of indexation. Replace the list view by a search view
ymh <ymh.work@gmail.com>
parents:
diff changeset
    12
from p4l.search.forms import RecordSearchForm
c05567404888 First version of indexation. Replace the list view by a search view
ymh <ymh.work@gmail.com>
parents:
diff changeset
    13
c05567404888 First version of indexation. Replace the list view by a search view
ymh <ymh.work@gmail.com>
parents:
diff changeset
    14
c05567404888 First version of indexation. Replace the list view by a search view
ymh <ymh.work@gmail.com>
parents:
diff changeset
    15
class RecordSearchView(SearchView):
c05567404888 First version of indexation. Replace the list view by a search view
ymh <ymh.work@gmail.com>
parents:
diff changeset
    16
    
c05567404888 First version of indexation. Replace the list view by a search view
ymh <ymh.work@gmail.com>
parents:
diff changeset
    17
    def __init__(self, template=None, load_all=True, form_class=None, searchqueryset=None, context_class=RequestContext, results_per_page=None):
c05567404888 First version of indexation. Replace the list view by a search view
ymh <ymh.work@gmail.com>
parents:
diff changeset
    18
        record_searchQuerySet = SearchQuerySet().order_by('identifier')
117
0a4e7d6ebe80 - Do not create object for new
ymh <ymh.work@gmail.com>
parents: 113
diff changeset
    19
        template = "p4l/home.html"
113
c05567404888 First version of indexation. Replace the list view by a search view
ymh <ymh.work@gmail.com>
parents:
diff changeset
    20
        results_per_page= settings.NB_RECORDS_BY_PAGE
c05567404888 First version of indexation. Replace the list view by a search view
ymh <ymh.work@gmail.com>
parents:
diff changeset
    21
        form_class = RecordSearchForm
c05567404888 First version of indexation. Replace the list view by a search view
ymh <ymh.work@gmail.com>
parents:
diff changeset
    22
        SearchView.__init__(self, template=template, load_all=False, form_class=form_class, searchqueryset=record_searchQuerySet, context_class=context_class, results_per_page=results_per_page)
c05567404888 First version of indexation. Replace the list view by a search view
ymh <ymh.work@gmail.com>
parents:
diff changeset
    23
c05567404888 First version of indexation. Replace the list view by a search view
ymh <ymh.work@gmail.com>
parents:
diff changeset
    24
    @classmethod
c05567404888 First version of indexation. Replace the list view by a search view
ymh <ymh.work@gmail.com>
parents:
diff changeset
    25
    def as_view(cls):
c05567404888 First version of indexation. Replace the list view by a search view
ymh <ymh.work@gmail.com>
parents:
diff changeset
    26
        return search_view_factory(view_class=cls)