search_indexes.py 743 Bytes
Newer Older
1 2 3
from haystack import indexes
from models import Operator, Violation

jc's avatar
jc committed
4

5 6 7 8
class ViolationIndexes(indexes.SearchIndex, indexes.Indexable):
    text = indexes.CharField(document=True, use_template=True)
    operator = indexes.CharField(model_attr="operator_ref")
    country = indexes.CharField(model_attr="country")
9 10 11
    contract = indexes.CharField(model_attr="contract")
    type = indexes.CharField(model_attr="contractual")
    media = indexes.CharField(model_attr="media")
okhin's avatar
okhin committed
12
    operator_name = indexes.CharField()
13
    state = indexes.NgramField(model_attr="state")
okhin's avatar
okhin committed
14
    old = indexes.BooleanField(model_attr="old")
15 16 17

    def get_model(self):
        return Violation
okhin's avatar
okhin committed
18 19 20

    def prepare_operator_name(self, obj):
        return obj.operator_ref.name