Browse Source

Added handling of no search results

master
David Winterbottom 14 years ago
parent
commit
9614ee181c
2 changed files with 30 additions and 24 deletions
  1. 1
    1
      oscar/apps/search/urls.py
  2. 29
    23
      oscar/templates/oscar/search/results.html

+ 1
- 1
oscar/apps/search/urls.py View File

@@ -16,5 +16,5 @@ for field_name, field in ProductIndex.fields.items():
16 16
 urlpatterns = patterns('search.apps.views',
17 17
     url(r'^suggest/$', Suggestions.as_view(), name='oscar-search-suggest'),
18 18
     url(r'^$', MultiFacetedSearchView(form_class=MultiFacetedSearchForm, 
19
-        searchqueryset=sqs), name='oscar-search'),
19
+                                      searchqueryset=sqs), name='oscar-search'),
20 20
 )

+ 29
- 23
oscar/templates/oscar/search/results.html View File

@@ -3,36 +3,42 @@
3 3
 {% load thumbnail %}
4 4
 
5 5
 {% block content %}
6
+
6 7
 <h2>Search for '{{ query }}'</h2>
7 8
 
8 9
 {% if suggestion %}
9 10
 Did you mean <a href="{% url oscar-search %}?q={{ suggestion }}">{{ suggestion }}</a>?
10 11
 {% endif %}
11 12
 
12
-<ol>
13
-{% for result in page.object_list %}
14
-<li>
15
-    {% for image in result.object.images.all %}
16
-        {% if forloop.first %}
17
-            {% thumbnail image.original "100" crop="center" as im %}
18
-                <a href="{{ result.object.get_absolute_url }}"><img src="{{ im.url }}" width="{{ im.width }}" height="{{ im.height }}"></a>
19
-            {% endthumbnail %}
20
-        {% endif %}
21
-    {% endfor %}
22
-    <a href="{{ result.object.get_absolute_url }}">{{ result.object.get_title }}</a><br/>
23
-    {% if result.object.is_group %}
24
-        From {{ result.object.min_variant_price_incl_tax|currency }}
25
-    {% else %}
26
-        {% if result.object.has_stockrecord %} 
27
-            {{ result.object.stockrecord.price_incl_tax|currency }}<br/>
28
-            {{ result.object.stockrecord.availability }}
13
+
14
+{% if page.object_list %}
15
+    <ol>
16
+    {% for result in page.object_list %}
17
+    <li>
18
+        {% for image in result.object.images.all %}
19
+            {% if forloop.first %}
20
+                {% thumbnail image.original "100" crop="center" as im %}
21
+                    <a href="{{ result.object.get_absolute_url }}"><img src="{{ im.url }}" width="{{ im.width }}" height="{{ im.height }}"></a>
22
+                {% endthumbnail %}
23
+            {% endif %}
24
+        {% endfor %}
25
+        <a href="{{ result.object.get_absolute_url }}">{{ result.object.get_title }}</a><br/>
26
+        {% if result.object.is_group %}
27
+            From {{ result.object.min_variant_price_incl_tax|currency }}
29 28
         {% else %}
30
-            Not available    
31
-        {% endif %}
32
-    {% endif %}    
33
-</li>
34
-{% endfor %}
35
-</ol>
29
+            {% if result.object.has_stockrecord %} 
30
+                {{ result.object.stockrecord.price_incl_tax|currency }}<br/>
31
+                {{ result.object.stockrecord.availability }}
32
+            {% else %}
33
+                Not available    
34
+            {% endif %}
35
+        {% endif %}    
36
+    </li>
37
+    {% endfor %}
38
+    </ol>
39
+{% else %}
40
+    No search results found.
41
+{% endif %}
36 42
 
37 43
 {% if page_obj %}
38 44
 <div class="pagination">

Loading…
Cancel
Save