#########################################################################
#
# Copyright (C) 2016 OSGeo
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
#########################################################################
from haystack import indexes
from django.contrib.auth import get_user_model
[docs]
class ProfileIndex(indexes.SearchIndex, indexes.Indexable):
[docs]
id = indexes.IntegerField(model_attr="id")
[docs]
username = indexes.CharField(model_attr="username", null=True)
[docs]
first_name = indexes.CharField(model_attr="first_name", null=True)
[docs]
last_name = indexes.CharField(model_attr="last_name", null=True)
[docs]
profile = indexes.CharField(model_attr="profile", null=True)
[docs]
organization = indexes.CharField(model_attr="organization", null=True)
[docs]
position = indexes.CharField(model_attr="position", null=True)
[docs]
text = indexes.CharField(document=True, use_template=True)
[docs]
type = indexes.CharField(faceted=True)
[docs]
def get_model(self):
return get_user_model()
[docs]
def prepare_title(self, obj):
return str(obj)
[docs]
def prepare_title_sort(self, obj):
return str(obj).lower().lstrip()
[docs]
def prepare_type(self, obj):
return "user"