more box fixes
authorRadek Czajka <radoslaw.czajka@nowoczesnapolska.org.pl>
Tue, 24 Jan 2012 15:51:33 +0000 (16:51 +0100)
committerRadek Czajka <radoslaw.czajka@nowoczesnapolska.org.pl>
Tue, 24 Jan 2012 15:51:33 +0000 (16:51 +0100)
apps/catalogue/models.py
apps/catalogue/templatetags/catalogue_tags.py
wolnelektury/templates/catalogue/book_short.html
wolnelektury/templates/catalogue/book_wide.html

index 03cf0c8..a944111 100644 (file)
@@ -788,7 +788,7 @@ class Book(models.Model):
             tags = split_tags(tags)
             for category in tags:
                 rel['tags'][category] = [
             tags = split_tags(tags)
             for category in tags:
                 rel['tags'][category] = [
-                        (t.name, t.get_absolute_url()) for t in tags[category]]
+                        (t.name, t.slug) for t in tags[category]]
 
             for media_format in BookMedia.formats:
                 rel['media'][media_format] = self.has_media(media_format)
 
             for media_format in BookMedia.formats:
                 rel['media'][media_format] = self.has_media(media_format)
index 542f1cd..c2d7dd6 100644 (file)
@@ -292,6 +292,7 @@ def book_wide(context, book):
 
     return {
         'book': book,
 
     return {
         'book': book,
+        'main_link': reverse('book_text', args=[book.slug]),
         'related': book.related_info(),
         'extra_info': book.get_extra_info_value(),
         'hide_about': hide_about,
         'related': book.related_info(),
         'extra_info': book.get_extra_info_value(),
         'hide_about': hide_about,
@@ -305,6 +306,7 @@ def book_wide(context, book):
 def book_short(context, book):
     return {
         'book': book,
 def book_short(context, book):
     return {
         'book': book,
+        'main_link': book.get_absolute_url(),
         'related': book.related_info(),
         'request': context.get('request'),
     }
         'related': book.related_info(),
         'request': context.get('request'),
     }
@@ -356,6 +358,13 @@ def related_books(book, limit=6):
     }
 
 
     }
 
 
+@register.simple_tag
+def tag_url(category, slug):
+    return reverse('catalogue.views.tagged_object_list', args=[
+        '/'.join((Tag.categories_dict[category], slug))
+    ])
+
+
 @register.filter
 @stringfilter
 def removewholetags(value, tags):
 @register.filter
 @stringfilter
 def removewholetags(value, tags):
index a6d3028..9eae96f 100644 (file)
@@ -1,11 +1,11 @@
 {% load i18n %}
 {% load i18n %}
-{% load social_tags %}
+{% load catalogue_tags social_tags %}
 {% load thumbnail %}
 <div class="{% block box-class %}book-box{% endblock %}">
 <div class="book-box-inner" style="position: relative;">
 
 
 {% load thumbnail %}
 <div class="{% block box-class %}book-box{% endblock %}">
 <div class="book-box-inner" style="position: relative;">
 
 
-    <a href="{{ book.get_absolute_url }}">
+    <a href="{{ main_link }}">
         {% if book.cover %}
             <img src="
                 {% thumbnail book.cover "139x193" as thumb %}
         {% if book.cover %}
             <img src="
                 {% thumbnail book.cover "139x193" as thumb %}
 
         <div class="book-box-head">
             <div class="mono author">
 
         <div class="book-box-head">
             <div class="mono author">
-                {% for name, url in related.tags.author %}
-                    <a href="{{ url }}">{{ name }}</a>{% if not forloop.last %},
+                {% for name, slug in related.tags.author %}
+                    <a href="{% tag_url 'author' slug %}">{{ name }}</a>{% if not forloop.last %},
                 {% endif %}{% endfor %}{% for title, slug in related.parents %},
                     <a href="{% url book_detail slug %}">{{ title }}</a>
                 {% endfor %}
             </div>
                 {% endif %}{% endfor %}{% for title, slug in related.parents %},
                     <a href="{% url book_detail slug %}">{{ title }}</a>
                 {% endfor %}
             </div>
-            <div class="title"><a href="{{ book.get_absolute_url }}">{{ book.title }}</a></div>
+            <div class="title"><a href="{{ main_link }}">{{ book.title }}</a></div>
         </div>
         <div class="tags">
             {% spaceless %}
 
             <span class="mono">{% trans "Epoch" %}:</span>&nbsp;<span class="book-box-tag">
         </div>
         <div class="tags">
             {% spaceless %}
 
             <span class="mono">{% trans "Epoch" %}:</span>&nbsp;<span class="book-box-tag">
-                {% for name, url in related.tags.epoch %}
-                    <a href="{{ url }}">{{ name }} </a>
+                {% for name, slug in related.tags.epoch %}
+                    <a href="{% tag_url 'epoch' slug %}">{{ name }} </a>
                 {% endfor %}
             </span>
 
             <span class="mono">{% trans "Kind" %}:</span>&nbsp;<span class="book-box-tag">
                 {% endfor %}
             </span>
 
             <span class="mono">{% trans "Kind" %}:</span>&nbsp;<span class="book-box-tag">
-                {% for name, url in related.tags.kind %}
-                    <a href="{{ url }}">{{ name }} </a>
+                {% for name, slug in related.tags.kind %}
+                    <a href="{% tag_url 'kind' slug %}">{{ name }} </a>
                 {% endfor %}
             </span>
 
             <span class="mono">{% trans "Genre" %}:</span>&nbsp;<span class="book-box-tag">
                 {% endfor %}
             </span>
 
             <span class="mono">{% trans "Genre" %}:</span>&nbsp;<span class="book-box-tag">
-                {% for name, url in related.tags.genre %}
-                    <a href="{{ url }}">{{ name }} </a>
+                {% for name, slug in related.tags.genre %}
+                    <a href="{% tag_url 'genre' slug %}">{{ name }} </a>
                 {% endfor %}
             </span>
 
                 {% endfor %}
             </span>
 
index dfe57b6..2ea5555 100644 (file)
@@ -15,7 +15,7 @@
         <div id="themes-list">
             <ul>
             {% for theme in themes %}
         <div id="themes-list">
             <ul>
             {% for theme in themes %}
-                <li><a href="{% url book_fragments book.urlid theme.slug %}">{{ theme }} ({{ theme.count }})</a></li>
+                <li><a href="{% url book_fragments book.slug theme.slug %}">{{ theme }} ({{ theme.count }})</a></li>
             {% endfor %}
             </ul>
         </div>
             {% endfor %}
             </ul>
         </div>