Fixes #3396: More pictures info.
authorRadek Czajka <radekczajka@nowoczesnapolska.org.pl>
Wed, 22 Oct 2014 08:55:56 +0000 (10:55 +0200)
committerRadek Czajka <radekczajka@nowoczesnapolska.org.pl>
Wed, 22 Oct 2014 08:57:01 +0000 (10:57 +0200)
apps/picture/migrations/0005_auto_20141022_1001.py [new file with mode: 0644]
apps/picture/templates/picture/picture_short.html
apps/picture/templates/picture/picture_wide.html
lib/librarian

diff --git a/apps/picture/migrations/0005_auto_20141022_1001.py b/apps/picture/migrations/0005_auto_20141022_1001.py
new file mode 100644 (file)
index 0000000..e5e8738
--- /dev/null
@@ -0,0 +1,24 @@
+# -*- coding: utf-8 -*-
+from __future__ import unicode_literals
+
+from django.db import models, migrations
+
+def rebuild_extra_info(apps, schema_editor):
+    Picture = apps.get_model("picture", "Picture")
+    from librarian.picture import PictureInfo
+    from librarian import dcparser
+    for pic in Picture.objects.all():
+        info = dcparser.parse(pic.xml_file.path, PictureInfo)
+        pic.extra_info = info.to_dict()
+        pic.save()
+
+
+class Migration(migrations.Migration):
+
+    dependencies = [
+        ('picture', '0004_auto_20141016_1337'),
+    ]
+
+    operations = [
+        migrations.RunPython(rebuild_extra_info),
+    ]
index 881dcfe..1bd70a1 100644 (file)
@@ -60,6 +60,9 @@
                 {% endfor %}
             </span></span>
 
+            {% block extra_categories %}
+            {% endblock %}
+
             {% endspaceless %}
         </div>
     </div>
index e2fab8c..9f47c7b 100644 (file)
 {% endblock %}
 
 
+{% block extra_categories %}
+{% if picture.extra_info.styles %}
+<span class="category">
+<span class="mono"> {% trans "Style" %}:</span>&nbsp;<span class="book-box-tag">
+    {% for tag in picture.extra_info.styles %}
+        <a>{{ tag }}</a>
+        {% if not forloop.last %}<span>, </span>{% endif %}
+    {% endfor %}
+</span></span>
+{% endif %}
+
+{% if picture.extra_info.medium %}
+<span class="category">
+<span class="mono"> {% trans "Medium" %}:</span>&nbsp;<span class="book-box-tag">
+    <a>{{ picture.extra_info.medium }}</a>
+</span></span>
+{% endif %}
+
+{% if picture.extra_info.original_dimensions %}
+<span class="category">
+<span class="mono"> {% trans "Dimensions" %}:</span>&nbsp;<span class="book-box-tag">
+    <a>{{ picture.extra_info.original_dimensions }}</a>
+</span></span>
+{% endif %}
+
+<span class="category">
+<span class="mono"> {% trans "Date" %}:</span>&nbsp;<span class="book-box-tag">
+    <a>{{ picture.extra_info.created_at }}</a>
+</span></span>
+
+{% endblock %}
+
+
 {% block book-box-extra-info %}
 {% if themes or things%}
     <div class="hidden-box-wrapper" id="theme-list-wrapper">
index a3b6840..a04f11b 160000 (submodule)
@@ -1 +1 @@
-Subproject commit a3b6840527ec52ce8b6d74819633d8c85e3973ba
+Subproject commit a04f11baee3eb7d090867c2d5639a120ec3217b8