Skip to content

Commit

Permalink
show alert when no results are found
Browse files Browse the repository at this point in the history
  • Loading branch information
carlosp420 committed Dec 19, 2014
1 parent 896ecd9 commit 2e4efc4
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
4 changes: 3 additions & 1 deletion voseq/public_interface/forms.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from django import forms
from haystack.forms import ModelSearchForm
from haystack.query import SearchQuerySet
from haystack.query import EmptySearchQuerySet


class AdvancedSearchForm(ModelSearchForm):
Expand Down Expand Up @@ -93,7 +94,8 @@ class AdvancedSearchForm(ModelSearchForm):
labPerson = forms.CharField(max_length=100, required=False)

def no_query_found(self):
return SearchQuerySet().none()
sqs = SearchQuerySet.none
return sqs

def search(self):
if not self.is_valid():
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
{% extends 'public_interface/base.html' %}

{% block content %}


<form method="get" action=".">
<div class="explorer-container">
<div class="container">
Expand All @@ -9,8 +11,12 @@ <h3>Search by querying a single field for any combination of fields</h3>
</div><!-- row -->

<div class="row">
<div class="col-lg-6">

{% if results == 'No results' %}
<div class="alert alert-warning"><b>No results were found</b></div>
{% endif %}

<div class="col-lg-6">
<div class="panel panel-primary">
<div class="panel-heading">
<h3 class="panel-title"><b>Search by taxonomy</b></h3>
Expand Down
3 changes: 3 additions & 0 deletions voseq/public_interface/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ def search(request):
if results:
return render(request, 'public_interface/search_results.html',
{'form': form, 'results': results})
else:
return render(request, 'public_interface/search.html',
{'form': form, 'results': 'No results'})
else:
form = AdvancedSearchForm()

Expand Down

0 comments on commit 2e4efc4

Please sign in to comment.