search_indexes.py 658 Bytes
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
from haystack import indexes
from models import Operator, Violation

class OperatorIndex(indexes.SearchIndex, indexes.Indexable):
    text = indexes.CharField(document=True, use_template=True)

    def get_model(self):
        return Operator

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")

    def get_model(self):
        return Violation