Added a verbose name field for collection objects, home view now gets a list of all collections
authordurandn
Mon, 11 Jul 2016 14:51:49 +0200
changeset 64 4d1e369e85d4
parent 63 96e35b9957ba
child 65 625ed1ba472f
Added a verbose name field for collection objects, home view now gets a list of all collections
src/iconolab/fixtures/demo_data.json
src/iconolab/migrations/0003_auto_20160711_1215.py
src/iconolab/models.py
src/iconolab/templates/iconolab/home.html
src/iconolab/views.py
--- a/src/iconolab/fixtures/demo_data.json	Mon Jul 11 11:47:46 2016 +0200
+++ b/src/iconolab/fixtures/demo_data.json	Mon Jul 11 14:51:49 2016 +0200
@@ -17,7 +17,8 @@
 	    "model": "iconolab.Collection",
 	    "pk": 1,
 	    "fields": {
-	    	"name": "ingres"
+	    	"name": "ingres",
+	    	"verbose_name": "Musée d'Ingres"
 	    }
 	},{
 	    "model": "iconolab.Item",
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/iconolab/migrations/0003_auto_20160711_1215.py	Mon Jul 11 14:51:49 2016 +0200
@@ -0,0 +1,51 @@
+# -*- coding: utf-8 -*-
+# Generated by Django 1.9.7 on 2016-07-11 12:15
+from __future__ import unicode_literals
+
+from django.db import migrations, models
+import django.db.models.deletion
+
+
+class Migration(migrations.Migration):
+
+    dependencies = [
+        ('iconolab', '0002_auto_20160627_1320'),
+    ]
+
+    operations = [
+        migrations.AddField(
+            model_name='collection',
+            name='verbose_name',
+            field=models.CharField(blank=True, max_length=50, null=True),
+        ),
+        migrations.AlterField(
+            model_name='annotationrevision',
+            name='merge_parent_revision',
+            field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='child_revisions_merge', to='iconolab.AnnotationRevision'),
+        ),
+        migrations.AlterField(
+            model_name='annotationrevision',
+            name='parent_revision',
+            field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='child_revisions', to='iconolab.AnnotationRevision'),
+        ),
+        migrations.AlterField(
+            model_name='annotationrevision',
+            name='state',
+            field=models.IntegerField(choices=[(0, 'awaiting'), (1, 'accepted'), (2, 'rejected'), (3, 'studied')], default=0),
+        ),
+        migrations.AlterField(
+            model_name='annotationrevision',
+            name='tags',
+            field=models.ManyToManyField(through='iconolab.TaggingInfo', to='iconolab.Tag'),
+        ),
+        migrations.AlterField(
+            model_name='collection',
+            name='name',
+            field=models.SlugField(unique=True),
+        ),
+        migrations.AlterField(
+            model_name='iconolabcomment',
+            name='metacategories',
+            field=models.ManyToManyField(through='iconolab.MetaCategoryInfo', to='iconolab.MetaCategory'),
+        ),
+    ]
--- a/src/iconolab/models.py	Mon Jul 11 11:47:46 2016 +0200
+++ b/src/iconolab/models.py	Mon Jul 11 14:51:49 2016 +0200
@@ -26,7 +26,8 @@
 
 
 class Collection(models.Model):
-    name =    models.CharField(max_length=50, unique=True)
+    name = models.SlugField(max_length=50, unique=True)
+    verbose_name = models.CharField(max_length=50, null=True, blank=True)
     description = models.CharField(max_length=255)
 
     def __str__(self):
--- a/src/iconolab/templates/iconolab/home.html	Mon Jul 11 11:47:46 2016 +0200
+++ b/src/iconolab/templates/iconolab/home.html	Mon Jul 11 14:51:49 2016 +0200
@@ -6,7 +6,10 @@
 {% load iconolab_tags %}
 
 {% block content %}
-<h1>Fond Ingres <a href="{% url 'collection_home' 'ingres' %}"><span class="glyphicon glyphicon-link" aria-hidden="true"></span></a></h1>
+
+{% for collection in collections.all %}
+<h1>Fond {{ collection.verbose_name }} <a href="{% url 'collection_home' collection.name %}"><span class="glyphicon glyphicon-link" aria-hidden="true"></span></a></h1>
+{% endfor %}
 
 {% get_current_language as LANGUAGE_CODE %}
 {% get_available_languages as LANGUAGES %}
--- a/src/iconolab/views.py	Mon Jul 11 11:47:46 2016 +0200
+++ b/src/iconolab/views.py	Mon Jul 11 14:51:49 2016 +0200
@@ -21,8 +21,9 @@
 
 class GlobalHomepageView(View):
     def get(self, request, *args, **kwargs):
-        # Handle homepage view here
-        return render(request, 'iconolab/home.html');
+        context = {}
+        context["collections"] = Collection.objects
+        return render(request, 'iconolab/home.html', context);
 
 
 class CollectionHomepageView(View, ContextMixin):