示例#1
0
    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)
示例#2
0
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
示例#3
0
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
示例#4
0
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)
示例#5
0
def fill_user_index(sender, instance, **kw):
    index = []
    if instance.name:
        index += split_string(instance.name)
    instance.index = index