def get_index(self):
        index = []

        if self.address:
            index += split_string(self.address)
        if self.neighborhood:
            index += split_string(self.neighborhood)
        if self.city:
            index += split_string(self.city)
        
        return set(index)
def fill_discipline_index(sender, instance, **kw):
    index = []
    if instance.name:
        index += split_string(instance.name)
    if instance.acronym:
        index += split_string(instance.acronym)
    if instance.description:
        index += split_string(instance.description)
    if instance.course:
        index += instance.course.index

    instance.index = index
def fill_institution_index(sender, instance, **kw):
    index = []
    if instance.name:
        index += split_string(instance.name)
    if instance.acronym:
        index += split_string(instance.acronym)
    if instance.description:
        index += split_string(instance.description)
    if instance.address:
        index += instance.address.get_index()

    instance.index = index
def search(request):
    words = split_string(request.GET.get('q', ''))

    queryU = UserInfo.objects.all()
    queryI = Institution.objects.all()
    queryC = Course.objects.all()
    queryD = Discipline.objects.all()

    for word in words:
        queryU = queryU.filter(index=word)
        queryI = queryI.filter(index=word)
        queryC = queryC.filter(index=word)
        queryD = queryD.filter(index=word)

    result = []
    result += list(queryU)
    result += list(queryI)
    result += list(queryC)
    result += list(queryD)

    ctx = {
        'result': result,
    }

    return direct_to_template(request, 'search/list.html', ctx)
def fill_user_index(sender, instance, **kw):
    index = []
    if instance.name:
        index += split_string(instance.name)
    instance.index = index