Beispiel #1
0
def search(request, item):
    item = item.replace("_", " ")
    lessons = Lesson.objects.filter(get_query(item, ["name",]))
    questions = UserQuestion.objects.filter(get_query(item, ["title",]))
    users = User.objects.filter(get_query(item, ["username",]))
    context = ({
        'search_term': item,
        'lessons': lessons,
        'questions': questions,
        'users': users,
    })
    return render(request, 'search.html', context)
Beispiel #2
0
 def list(self, request):
     query_string = ''
     entries = Person.objects.all()
     # Search 
     if ('q' in request.GET) and request.GET['q'].strip():
         query_string = request.GET['q']
         # you can add additional fields if needed
         entry_query = search.get_query(query_string, ['givenName', 'surName','displayName','mail','telephoneNumber','employeeID','studentID'])
         entries = entries.filter(entry_query)
     # Affiliation filter
     if ('affiliation' in request.GET):
         query_string = request.GET['affiliation']
         entries = entries.filter(affiliations__affiliation=query_string)
     # 5 persons / page
     paginator = Paginator(entries, 5)
     page = request.QUERY_PARAMS.get('page')
     try:
         paged_entries = paginator.page(page)
     except PageNotAnInteger:
         # If page is not an integer, deliver first page.
         paged_entries = paginator.page(1)
     except EmptyPage:
         # If page is out of range (e.g. 9999),
         # deliver last page of results.
         paged_entries = paginator.page(paginator.num_pages)
     serializer = PaginatedPersonSerializer(paged_entries, context={'request': request})
     return Response(serializer.data)
Beispiel #3
0
    def filter_products(cls, search=None, filter_by=None):

        fields = [
            'title', 'category__slug', 'sub_a__slug', 'brand__slug',
            'sub_b__slug'
        ]
        query = get_query(search, fields, filter_by)
        products = cls.objects.filter(query)
        return products
def search(request):
	query_string = ''
	found_entries = None
	if ('q' in request.GET) and request.GET['q'].strip():
		query_string = request.GET['q']

		entry_query = get_query(query_string, ['name', 'kind', 'location', 'citations'])
		per_entries = Person.objects.filter(entry_query)

		entry_query = get_query(query_string, ['name', 'kind', 'location', 'history'])
		org_entries = Organization.objects.filter(entry_query)

		entry_query = get_query(query_string, ['name', 'kind', 'locations'])
		cri_entries = Crisis.objects.filter(entry_query)

		found_entries = list(chain(per_entries, org_entries, cri_entries))
	return render_to_response('search.html', { 'query_string': found_entries}, 
								context_instance=RequestContext(request))
Beispiel #5
0
def _db_search(request):
    if ('q' in request.GET) and request.GET['q'].strip():
        query_string_base = request.GET['q']
        query_string = unicodedata.normalize('NFKC', query_string_base)
        entry_query = get_query(query_string, ['title', 'content'])
        found_entries = Entry.objects.filter(entry_query).order_by('-pub_date')
        context = {'query_string': query_string}
        return paginated_view(request, found_entries, html_file='blog/search.html', context=context)
    else:
        return index(request)
Beispiel #6
0
def entry_list_filter(request, keyword):
    query_string_base = keyword
    query_string = unicodedata.normalize("NFKC", query_string_base)
    entry_query = get_query(query_string, ["title"])
    found_entries = Entry.objects.filter(entry_query).order_by("-pub_date")[:20]

    response = ""
    for entry_obj in found_entries:
        response += "%i, %s, %s\n" % (entry_obj.id, str(entry_obj.pub_date), entry_obj.title)

    return HttpResponse(response)
Beispiel #7
0
 def search(self, request):
     found_entries = None
     if ('q' in request.GET) and request.GET['q'].strip():
         query_string = request.GET['q']
         entry_query = get_query(query_string, ['title'])
         found_entries = Item.objects.filter(entry_query).order_by('-edit_date')
         if 'maxPrice' in request.GET and request.GET['maxPrice']:
             try:
                 maxPrice = float(request.GET['maxPrice'])
                 found_entries = found_entries.filter(price__lte=maxPrice)
             except ValueError:
                 found_entries = None
     return found_entries
def search(request):
    query_string = ''
    found_entries = None

    if ('q' in request.GET) and request.GET['q'].strip():

        query_string = request.GET['q']

        entry_query = get_query(
            query_string, ['title', 'description', 'location', 'category'])
        found_entries = Event.objects.filter(entry_query)
        events = filterOutPastEvents(found_entries)
        results = [e.to_json() for e in events]
    else:  #the user searched for an empty query, so return all results
        events = Event.objects.all()
        events = filterOutPastEvents(events)
        results = [e.to_json() for e in events]
    return JsonResponse(results, safe=False)
def search(request):
    query_string = ''
    found_entries = None
    if ('term' in request.GET) and request.GET['term'].strip():
        query_string = request.GET['term']

        entry_query = get_query(query_string, ['title'])

        found_entries = Glossary.objects.filter(entry_query).order_by('title')

        return_entries = []

        for entry in found_entries:

            return_entries.append({'label': entry.title, 'value': entry.description})



        return HttpResponse(simplejson.dumps(return_entries), content_type='application/json')

    return HttpResponse(simplejson.dumps([]), content_type='application/json')
def search(request):
    query_string = ''
    found_entries = None
    if ('term' in request.GET) and request.GET['term'].strip():
        query_string = request.GET['term']

        entry_query = get_query(query_string, ['title'])

        found_entries = Glossary.objects.filter(entry_query).order_by('title')

        return_entries = []

        for entry in found_entries:
            #return_entries.append({'title': entry.title, 'description': entry.description})
            #return_entries.append(entry.title)
            return_entries.append({'label': entry.title, 'value': entry.description})



        return HttpResponse(simplejson.dumps(return_entries), content_type='application/json')

    return HttpResponse(simplejson.dumps([]), content_type='application/json')
Beispiel #11
0
def search(request):
    if 'search' in request.GET:
        query = request.GET['search']
        if query != "" and query.strip() != "": 
            playlist_list = Playlist.objects.filter(get_query(query, ['name'])).order_by('-upvotes')
    return render_to_response('search.html', {'playlist_list': playlist_list})