Fixed #724: nicer search results
authorRadek Czajka <radoslaw.czajka@nowoczesnapolska.org.pl>
Tue, 6 Jul 2010 11:29:43 +0000 (13:29 +0200)
committerRadek Czajka <radoslaw.czajka@nowoczesnapolska.org.pl>
Tue, 6 Jul 2010 11:30:05 +0000 (13:30 +0200)
apps/catalogue/templatetags/catalogue_tags.py
apps/catalogue/views.py
wolnelektury/static/css/master.css
wolnelektury/templates/catalogue/search_multiple_hits.html

index 25376f8..9475348 100644 (file)
@@ -61,9 +61,16 @@ def simple_title(tags):
     return capfirst(', '.join(title))
 
 
+def book_stub_title(book):
+    return ', '.join((book.author, book.title))
+
+
 @register.simple_tag
 def book_title(book, html_links=False):
-    names = list(book.tags.filter(category='author'))
+    try:
+        names = list(book.tags.filter(category='author'))
+    except AttributeError:
+        return book_stub_title(book)
 
     books = []
     while book:
index cd74ac0..7322210 100644 (file)
@@ -320,7 +320,7 @@ def _get_result_type(match):
         type = 'book'
     else:
         type = match.category
-    return dict(models.TAG_CATEGORIES)[type]
+    return type
 
 
 
index 645466c..7440827 100644 (file)
@@ -203,6 +203,14 @@ p .ac_input {
 }
 
 
+/* ================== */
+/* = Search matches = */
+/* ================== */
+
+.matches li:first-letter {
+    text-transform: uppercase;
+}
+
 /* ============= */
 /* = Tags list = */
 /* ============= */
index 8e99cdc..b569e7d 100644 (file)
 
     <div id="books-list">
         <p>{% trans "More than one result matching the criteria found." %}</p>
-               <ul class='matches'>
+        <ul class='matches'>
         {% for match, link, type in results %}
-            <li><a href='{{ link }}'>{{ match.name }}</a> ({{ type }})</li>
+          <li>{% trans type %}: <a href='{{ link }}'>
+            {% ifequal type "book" %}
+                {% book_title match %}
+            {% else %}
+                {{ match.name }}
+            {% endifequal %}
+          </a></li>
         {% endfor %}
-               </ul>
+        </ul>
     </div>
 
     <div id="set-window">