search_indexes.py 603 Bytes
Newer Older
1
2
3
4
5
6
7
8
9
from haystack import indexes
from models import Operator, Violation

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")
    contract = indexes.CharField(model_attr="contract_excerpt")
    type = indexes.BooleanField(model_attr="contractual")
Okhin's avatar
Okhin committed
10
    operator_name = indexes.CharField()
11
12
13

    def get_model(self):
        return Violation
Okhin's avatar
Okhin committed
14
15
16

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