# HG changeset patch # User Alexandre Segura # Date 1492180531 -7200 # Node ID 655136b09cf3ef010f38c6d432a4319e10a71e89 # Parent a4d4774eb146edb9da644240d32b026e8d0a4e0c Introduce more fields in Folder model. diff -r a4d4774eb146 -r 655136b09cf3 src/iconolab/migrations/0020_auto_20170414_1424.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/iconolab/migrations/0020_auto_20170414_1424.py Fri Apr 14 16:35:31 2017 +0200 @@ -0,0 +1,38 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.10.5 on 2017-04-14 14:24 +from __future__ import unicode_literals + +from django.db import migrations, models +import django.db.models.deletion +import uuid + + +class Migration(migrations.Migration): + + dependencies = [ + ('iconolab', '0019_auto_20170309_1022'), + ] + + operations = [ + migrations.AddField( + model_name='folder', + name='collection', + field=models.ForeignKey(default=None, on_delete=django.db.models.deletion.CASCADE, related_name='folders', to='iconolab.Collection'), + preserve_default=False, + ), + migrations.AddField( + model_name='folder', + name='description', + field=models.TextField(blank=True, null=True), + ), + migrations.AddField( + model_name='folder', + name='folder_guid', + field=models.UUIDField(default=uuid.uuid4, editable=False), + ), + migrations.AddField( + model_name='folder', + name='original_id', + field=models.CharField(blank=True, max_length=256, null=True), + ), + ] diff -r a4d4774eb146 -r 655136b09cf3 src/iconolab/models.py --- a/src/iconolab/models.py Thu Apr 13 17:09:17 2017 +0200 +++ b/src/iconolab/models.py Fri Apr 14 16:35:31 2017 +0200 @@ -43,10 +43,6 @@ width = models.IntegerField(null=True, blank=True) show_image_on_home = models.BooleanField(default=False) - @property - def folders(self): - return Folder.objects.filter(item__collection=self).distinct() - def __str__(self): return self.name @@ -54,7 +50,11 @@ """ Some items may belong to a "folder". This is actually a physical folder """ + folder_guid = models.UUIDField(default=uuid.uuid4, editable=False) + collection = models.ForeignKey(Collection, related_name="folders") name = models.TextField(null=False, blank=False) + description = models.TextField(null=True, blank=True) + original_id = models.CharField(max_length=256, null=True, blank=True) def __str__(self): return 'Folder ' + self.name diff -r a4d4774eb146 -r 655136b09cf3 src/iconolab/templates/iconolab/collection_home.html --- a/src/iconolab/templates/iconolab/collection_home.html Thu Apr 13 17:09:17 2017 +0200 +++ b/src/iconolab/templates/iconolab/collection_home.html Fri Apr 14 16:35:31 2017 +0200 @@ -16,10 +16,10 @@

{{ collection.description | safe }}

- {% if collection.folders %} -

{{ collection.folders|length }} dossier{% if collection.folders|length > 1 %}s{% endif %}

+ {% if collection.folders.exists %} +

{{ collection.folders.count }} dossier{% if collection.folders.count > 1 %}s{% endif %}