|
|
|
|
@ -9,13 +9,52 @@ from models import Exposition |
|
|
|
|
from accounts.models import User |
|
|
|
|
from functions.custom_views import ExpoListView, ExpoMixin, EventDetail |
|
|
|
|
from django.views.generic import ListView, DetailView |
|
|
|
|
from haystack.query import EmptySearchQuerySet |
|
|
|
|
from functions.search_forms import ExpositionSearchForm |
|
|
|
|
# |
|
|
|
|
import json |
|
|
|
|
from django.utils.translation import ugettext as _ |
|
|
|
|
|
|
|
|
|
class ExpositionSearchView(ListView): |
|
|
|
|
paginate_by = 2 |
|
|
|
|
template_name = 'exposition/search.html' |
|
|
|
|
search_form = ExpositionSearchForm |
|
|
|
|
model = Exposition |
|
|
|
|
|
|
|
|
|
def get_queryset(self): |
|
|
|
|
|
|
|
|
|
if self.request.GET: |
|
|
|
|
form = self.search_form(self.request.GET) |
|
|
|
|
if form.is_valid(): |
|
|
|
|
return form.search() |
|
|
|
|
else: |
|
|
|
|
return EmptySearchQuerySet() |
|
|
|
|
else: |
|
|
|
|
return EmptySearchQuerySet() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def get_context_data(self, **kwargs): |
|
|
|
|
context = super(ExpositionSearchView, self).get_context_data(**kwargs) |
|
|
|
|
|
|
|
|
|
context['search_form'] = ExpositionSearchForm(self.request.GET) |
|
|
|
|
queries = self.request.GET.copy() |
|
|
|
|
if queries.has_key('page'): |
|
|
|
|
del queries['page'] |
|
|
|
|
context['queries'] = queries |
|
|
|
|
context['search_action'] = '/expositions/search/' |
|
|
|
|
|
|
|
|
|
return context |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class ExpositionView(ExpoListView): |
|
|
|
|
model = Exposition |
|
|
|
|
template_name = 'event_catalog.html' |
|
|
|
|
search_form = ExpositionSearchForm |
|
|
|
|
|
|
|
|
|
def get_context_data(self, **kwargs): |
|
|
|
|
context = super(ExpositionView, self).get_context_data(**kwargs) |
|
|
|
|
context['search_action'] = '/expositions/search/' |
|
|
|
|
return context |
|
|
|
|
|
|
|
|
|
class ExpositionVisitors(ExpositionView): |
|
|
|
|
model = Exposition |
|
|
|
|
|