-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
692fc02
commit 64a2f60
Showing
5 changed files
with
1 addition
and
180 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,39 +1,7 @@ | ||
import urllib | ||
|
||
from django.shortcuts import render | ||
from django.utils.datastructures import MultiValueDictKeyError | ||
from django.views.decorators.csrf import csrf_exempt | ||
|
||
from cazador.forms import CazadorForm | ||
from visitors.views import do_pagination | ||
|
||
|
||
@csrf_exempt | ||
def index(request): | ||
try: | ||
original_query = request.GET['q'] | ||
except MultiValueDictKeyError: | ||
return render(request, "cazador/index.html") | ||
|
||
all_items = [] | ||
query_list = original_query.splitlines() | ||
for query in query_list: | ||
request_query = {'q': query} | ||
form = CazadorForm(request_query) | ||
query_results = form.search() | ||
all_items += query_results | ||
|
||
search_queryset = list(set(all_items)) | ||
paginator, page = do_pagination(request, search_queryset) | ||
|
||
return render( | ||
request, | ||
"cazador/results.html", | ||
context={ | ||
"paginator": paginator, | ||
"page": page, | ||
"query": "; ".join(query_list), | ||
"original_query": original_query, | ||
"encoded_query": urllib.parse.quote_plus(original_query.strip()), | ||
} | ||
) | ||
return render(request, "cazador/index.html") |