You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
63 lines
1.9 KiB
63 lines
1.9 KiB
# -*- coding: utf-8 -*-
|
|
from django.http import HttpResponse
|
|
from models import Company
|
|
from functions.custom_views import ExpoListView
|
|
from django.views.generic import ListView, FormView
|
|
from haystack.query import EmptySearchQuerySet
|
|
import json
|
|
from functions.search_forms import CompanySearchForm
|
|
|
|
|
|
class CompanySearchView(ListView):
|
|
paginate_by = 2
|
|
template_name = 'company/search.html'
|
|
search_form = CompanySearchForm
|
|
model = Company
|
|
|
|
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(CompanySearchView, self).get_context_data(**kwargs)
|
|
|
|
context['search_form'] = CompanySearchForm(self.request.GET)
|
|
queries = self.request.GET.copy()
|
|
if queries.has_key('page'):
|
|
del queries['page']
|
|
context['queries'] = queries
|
|
context['search_action'] = '/members/search/'
|
|
|
|
return context
|
|
|
|
|
|
class CompanyView(ExpoListView):
|
|
model = Company
|
|
template_name = 'company_catalog.html'
|
|
search_form = CompanySearchForm
|
|
|
|
def get_context_data(self, **kwargs):
|
|
context = super(CompanyView, self).get_context_data(**kwargs)
|
|
context['search_action'] = '/members/search/'
|
|
return context
|
|
|
|
class CompanyExposition(CompanyView):
|
|
template_name = 'test_list.html'
|
|
|
|
def get_queryset(self):
|
|
|
|
params = self.get_params()
|
|
for param in params:
|
|
if param.get('type') == 'event':
|
|
company = Company.objects.safe_get(url=param.get('url'))
|
|
#query = exp.users
|
|
self.params = params
|
|
return company.exposition_companies.all() |