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.
 
 
 
 
 
 

73 lines
1.7 KiB

# -*- coding: utf-8 -*-
from haystack import indexes
class ExpoSearchMixin(object):
"""
"""
def prepare_where(self, obj):
if obj.country:
country = [tr.name for tr in obj.country.translations.all()]
else:
country = []
if obj.city:
city = [tr.name for tr in obj.city.translations.all()]
else:
city = []
return country + city
def prepare_content_auto(self, obj):
"""
object must have get_index_text method which generate text for searching
"""
return obj.get_index_text()
def prepare_area_id(self, obj):
if obj.country:
return obj.country.area.id
return None
def prepare_country_id(self, obj):
if obj.country:
return obj.country.id
return None
def prepare_city_id(self, obj):
if obj.city:
return obj.city.id
return None
def prepare_theme(self, obj):
return [th.id for th in obj.theme.filter()]
def prepare_tag(self, obj):
return [th.id for th in obj.tag.filter()]
def prepare_url(self, obj):
return obj.get_permanent_url()
def prepare_name_en(self, obj):
try:
return obj.translations.get(language_code = 'en').name
except:
return ''
def prepare_name_ru(self, obj):
try:
return obj.translations.get(language_code = 'ru').name
except:
return ''
def prepare_members_choice(self, obj):
return obj.members_choice or 0
def prepare_visitors_choice(self, obj):
return obj.visitors_choice or 0
def prepare_price_choice(self, obj):
return obj.price_choice or 0