diff --git a/static/css/custom.css b/static/css/custom.css
index 00c5657..7b23a1a 100644
--- a/static/css/custom.css
+++ b/static/css/custom.css
@@ -9,3 +9,14 @@
color: inherit;
font-weight: bold;
}
+
+.containericon {
+ white-space: nowrap;
+ display: inline-block;
+ vertical-align: middle;
+}
+
+.containericon span {
+ padding-left: 0.5rem;
+ font-weight: bold;
+}
diff --git a/static/icons/pappis.svg b/static/icons/pappis.svg
new file mode 100644
index 0000000..b314a3d
--- /dev/null
+++ b/static/icons/pappis.svg
@@ -0,0 +1,61 @@
+
+
diff --git a/static/icons/samla.svg b/static/icons/samla.svg
new file mode 100644
index 0000000..a645f4a
--- /dev/null
+++ b/static/icons/samla.svg
@@ -0,0 +1,47 @@
+
+
diff --git a/storage/migrations/0006_category_icon_id.py b/storage/migrations/0006_category_icon_id.py
new file mode 100644
index 0000000..89898d0
--- /dev/null
+++ b/storage/migrations/0006_category_icon_id.py
@@ -0,0 +1,20 @@
+# -*- coding: utf-8 -*-
+# Generated by Django 1.10.1 on 2017-10-24 17:48
+from __future__ import unicode_literals
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('storage', '0005'),
+ ]
+
+ operations = [
+ migrations.AddField(
+ model_name='category',
+ name='icon_id',
+ field=models.CharField(blank=True, max_length=64, null=True),
+ ),
+ ]
diff --git a/storage/models.py b/storage/models.py
index a198a28..edd40dc 100644
--- a/storage/models.py
+++ b/storage/models.py
@@ -24,6 +24,8 @@ STATES = (
class Category(models.Model):
name = models.CharField(max_length=127)
+ icon_id = models.CharField(max_length=64, null=True, blank=True)
+
def __str__(self):
return self.name
@@ -74,6 +76,10 @@ class Item(models.Model, TreeModelMixin):
return obj
+ @property
+ def primary_category(self):
+ return next((c for c in self.categories.all() if c.icon_id), None)
+
class Meta:
ordering = ('path',)
diff --git a/storage/templates/item.html b/storage/templates/item.html
index 3da0747..f105b6a 100644
--- a/storage/templates/item.html
+++ b/storage/templates/item.html
@@ -10,6 +10,8 @@
+
+ {% include "widgets/categoryicon.html" with category=item.primary_category %}
{{ item.name }} {{ item.pk }}
@@ -49,6 +51,22 @@
{% endfor %}
+ {% if categories %}
+
Categories
+
+ {% for category in categories %}
+
+
+ {% include "widgets/categoryicon.html" with category=category %}
+ |
+
+ {{ category.name }}
+ |
+
+ {% endfor %}
+
+ {% endif %}
+
{% if images %}
Photos
@@ -80,17 +98,7 @@
{% endif %}
Children
-
+ {% include "widgets/itemlist.html" with list=children|dictsort:"name" item=item %}
{% endblock %}
diff --git a/storage/templates/results.html b/storage/templates/results.html
index 4d61920..ce5f7f4 100644
--- a/storage/templates/results.html
+++ b/storage/templates/results.html
@@ -1,16 +1,5 @@
{% extends "base.html" %}
{% block content %}
-
- {% for item in results %}
-
-
- {% for parent in item.get_ancestors %}
- {{ parent.name }} »
- {% endfor %}
- {{ item.name }}
- |
-
- {% endfor %}
-
+ {% include "widgets/itemlist.html" with list=results show_paths=True show_placeholder=True %}
{% endblock %}
diff --git a/storage/views.py b/storage/views.py
index 4d6088e..c66ed13 100644
--- a/storage/views.py
+++ b/storage/views.py
@@ -62,10 +62,11 @@ def item_display(request, pk):
return render(request, 'item.html', {
'item': item,
+ 'categories': item.categories.all(),
'images': item.images.all(),
'labels': item.labels.all(),
'ancestors': item.get_ancestors(),
- 'children': item.get_children(),
+ 'children': item.get_children().prefetch_related('categories'),
})
def label_lookup(request, pk):
diff --git a/templates/widgets/categoryicon.html b/templates/widgets/categoryicon.html
new file mode 100644
index 0000000..e3b6b20
--- /dev/null
+++ b/templates/widgets/categoryicon.html
@@ -0,0 +1,3 @@
+{% if category and category.icon_id %}
+
+{% endif %}
diff --git a/templates/widgets/itemlist.html b/templates/widgets/itemlist.html
new file mode 100644
index 0000000..f58ecbf
--- /dev/null
+++ b/templates/widgets/itemlist.html
@@ -0,0 +1,32 @@
+
+ {% for item in list %}
+
+
+ {% include "widgets/categoryicon.html" with category=item.primary_category %}
+ |
+
+ {% if show_paths %}
+ {% for parent in item.get_ancestors %}
+ {{ parent.name }} »
+ {% endfor %}
+ {% endif %}
+ {{ item.name }}
+ |
+
+ {% empty %}
+ {% if show_placeholder %}
+
+ Nothing found |
+
+ {% endif %}
+ {% endfor %}
+
+ {% if item %}
+
+
+
+ Add child
+
+ |
+ {% endif %}
+