blob: 67d57237d049bbbeb550a78c41d96b46f5428ce9 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
# -*- coding: utf-8 -*-
from haystack import indexes
from indicator import models as im
# IndicatorCategoryIndex {{{
class IndicatorCategoryIndex(indexes.SearchIndex, indexes.Indexable):
"""
search index for 'Indicator'
"""
text = indexes.CharField(document=True, use_template=True)
addByUser = indexes.CharField(model_attr='addByUser')
def get_model(self):
return im.IndicatorCategory
def index_queryset(self, using=None):
"""
used when the entire index for model is updated
"""
return self.get_model().objects.all()
# }}}
# IndicatorIndex {{{
class IndicatorIndex(indexes.SearchIndex, indexes.Indexable):
"""
search index for 'Indicator'
"""
text = indexes.CharField(document=True, use_template=True)
addByUser = indexes.CharField(model_attr='addByUser')
dataType = indexes.CharField(model_attr='dataType')
categories_id = indexes.MultiValueField()
def get_model(self):
return im.Indicator
def prepare_categories(self, obj):
return [c.id for c in obj.categories.all()]
def index_queryset(self, using=None):
"""
used when the entire index for model is updated
"""
return self.get_model().objects.all()
# }}}
# vim: set ts=4 sw=4 tw=0 fenc=utf-8 ft=python:
|