no ssi for picture short
authorJan Szejko <janek37@gmail.com>
Fri, 23 Feb 2018 11:30:42 +0000 (12:30 +0100)
committerJan Szejko <janek37@gmail.com>
Fri, 23 Feb 2018 11:30:42 +0000 (12:30 +0100)
src/picture/models.py
src/picture/templates/picture/picture_short.html
src/picture/templates/picture/picture_viewer.html
src/picture/views.py

index 7732e20..47af34e 100644 (file)
@@ -14,6 +14,7 @@ from fnpdjango.utils.text.slughifi import slughifi
 from ssify import flush_ssi_includes
 
 from catalogue.models.tag import prefetched_relations
+from catalogue.utils import split_tags
 from picture import tasks
 from StringIO import StringIO
 import jsonfield
@@ -139,6 +140,9 @@ class Picture(models.Model):
     def author_unicode(self):
         return self.tag_unicode('author')
 
+    def tags_by_category(self):
+        return split_tags(self.tags)
+
     @permalink
     def get_absolute_url(self):
         return 'picture.views.picture_detail', [self.slug]
index 05a0398..a065d4b 100644 (file)
@@ -6,63 +6,67 @@
 <div class="{% block box-class %}book-box{% endblock %} picture">
   <div class="book-box-inner">
     <div class="book-box-body">
-      <div class="book-box-head">
-          <div class="author">
-              {% for tag in tags.author %}
-                  <a href="{{ tag.get_absolute_gallery_url }}">{{ tag }}</a>{% if not forloop.last %},
-              {% endif %}{% endfor %}
-          </div>
-          <div class="title">
-              {% if main_link %}<a href="{{ main_link }}">{% endif %}
-                  {{ picture.title }}
-              {% if main_link %}</a>{% endif %}
-          </div>
-      </div>
+      {% with picture.get_absolute_url as main_link %}
+      {% with picture.tags_by_category as tags %}
+        <div class="book-box-head">
+            <div class="author">
+                {% for tag in tags.author %}
+                    <a href="{{ tag.get_absolute_gallery_url }}">{{ tag }}</a>{% if not forloop.last %},
+                {% endif %}{% endfor %}
+            </div>
+            <div class="title">
+                {% if main_link %}<a href="{{ main_link }}">{% endif %}
+                    {{ picture.title }}
+                {% if main_link %}</a>{% endif %}
+            </div>
+        </div>
 
-      <div class="cover-area">
-        {% block picture-view %}
-        {% if main_link %}<a href="{{ main_link }}">{% endif %}
-          {% thumbnail picture.image_file "216x288" crop="center" as thumb %}
-          <img class="cover" src="{{thumb.url}}"/>
-          {% endthumbnail %}
-        {% if main_link %}</a>{% endif %}
-        {% endblock %}
-         {# what about licensing icons here #}
-      </div>
+        <div class="cover-area">
+          {% block picture-view %}
+          {% if main_link %}<a href="{{ main_link }}">{% endif %}
+            {% thumbnail picture.image_file "216x288" crop="center" as thumb %}
+            <img class="cover" src="{{thumb.url}}"/>
+            {% endthumbnail %}
+          {% if main_link %}</a>{% endif %}
+          {% endblock %}
+           {# what about licensing icons here #}
+        </div>
 
-      <div class="tags">
-        {% spaceless %}
-          <span class="category">
-            <span class="mono"> {% trans "Epoch" %}:</span>&nbsp;<span class="book-box-tag">
-              {% for tag in tags.epoch %}
-                <a href="{{ tag.get_absolute_gallery_url }}">{{ tag }}</a>
-                {% if not forloop.last %}<span>, </span>{% endif %}
-              {% endfor %}
+        <div class="tags">
+          {% spaceless %}
+            <span class="category">
+              <span class="mono"> {% trans "Epoch" %}:</span>&nbsp;<span class="book-box-tag">
+                {% for tag in tags.epoch %}
+                  <a href="{{ tag.get_absolute_gallery_url }}">{{ tag }}</a>
+                  {% if not forloop.last %}<span>, </span>{% endif %}
+                {% endfor %}
+              </span>
             </span>
-          </span>
 
-          <span class="category">
-            <span class="mono"> {% trans "Kind" %}:</span>&nbsp;<span class="book-box-tag">
-              {% for tag in tags.kind %}
-                <a href="{{ tag.get_absolute_gallery_url }}">{{ tag }}</a>
-                {% if not forloop.last %}<span>, </span>{% endif %}
-              {% endfor %}
+            <span class="category">
+              <span class="mono"> {% trans "Kind" %}:</span>&nbsp;<span class="book-box-tag">
+                {% for tag in tags.kind %}
+                  <a href="{{ tag.get_absolute_gallery_url }}">{{ tag }}</a>
+                  {% if not forloop.last %}<span>, </span>{% endif %}
+                {% endfor %}
+              </span>
             </span>
-          </span>
 
-          <span class="category">
-            <span class="mono"> {% trans "Genre" %}:</span>&nbsp;<span class="book-box-tag">
-              {% for tag in tags.genre %}
-                <a href="{{ tag.get_absolute_gallery_url }}">{{ tag }}</a>
-                {% if not forloop.last %}<span>, </span>{% endif %}
-              {% endfor %}
+            <span class="category">
+              <span class="mono"> {% trans "Genre" %}:</span>&nbsp;<span class="book-box-tag">
+                {% for tag in tags.genre %}
+                  <a href="{{ tag.get_absolute_gallery_url }}">{{ tag }}</a>
+                  {% if not forloop.last %}<span>, </span>{% endif %}
+                {% endfor %}
+              </span>
             </span>
-          </span>
 
-          {% block extra_categories %}
-          {% endblock %}
-        {% endspaceless %}
-      </div>
+            {% block extra_categories %}
+            {% endblock %}
+          {% endspaceless %}
+        </div>
+      {% endwith %}
+      {% endwith %}
     </div>
     <ul class="book-box-tools">
       <li class="book-box-read">
index bfa87b7..d23148f 100644 (file)
@@ -99,6 +99,6 @@
   </div>
 
   <div class="box Picture-item" id="book-short">
-    {% ssi_include 'picture_short' pk=picture.pk %}
+    {% include 'picture/picture_short.html' %}
   </div>
 {% endblock %}
index 381866a..6ace134 100644 (file)
@@ -141,10 +141,7 @@ def picture_short(request, pk):
 
     return render(request, 'picture/picture_short.html', {
         'picture': picture,
-        'main_link': picture.get_absolute_url(),
-        'request': request,
-        'tags': split_tags(picture.tags),
-        })
+    })
 
 
 @ssi_included