From 2b4f30c6225a2dfd00afcf42feccac13ca199e01 Mon Sep 17 00:00:00 2001 From: Radek Czajka Date: Tue, 6 Jul 2021 14:09:32 +0200 Subject: [PATCH 1/1] Add notes to collections in catalogue. --- src/catalogue/admin.py | 2 +- .../migrations/0030_auto_20210706_1408.py | 23 +++++++++++++++++++ src/catalogue/models.py | 2 ++ 3 files changed, 26 insertions(+), 1 deletion(-) create mode 100644 src/catalogue/migrations/0030_auto_20210706_1408.py diff --git a/src/catalogue/admin.py b/src/catalogue/admin.py index a6289613..8ce330ce 100644 --- a/src/catalogue/admin.py +++ b/src/catalogue/admin.py @@ -137,7 +137,7 @@ class CollectionAdmin(admin.ModelAdmin): autocomplete_fields = [] prepopulated_fields = {"slug": ("name",)} search_fields = ["name"] - fields = ['name', 'slug', 'category', 'estimated_costs'] + fields = ['name', 'slug', 'category', 'notes', 'estimated_costs'] readonly_fields = ['estimated_costs'] inlines = [AuthorInline, BookInline] diff --git a/src/catalogue/migrations/0030_auto_20210706_1408.py b/src/catalogue/migrations/0030_auto_20210706_1408.py new file mode 100644 index 00000000..17b14b83 --- /dev/null +++ b/src/catalogue/migrations/0030_auto_20210706_1408.py @@ -0,0 +1,23 @@ +# Generated by Django 3.1.13 on 2021-07-06 14:08 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('catalogue', '0029_auto_20201102_1315'), + ] + + operations = [ + migrations.AddField( + model_name='collection', + name='notes', + field=models.TextField(blank=True, verbose_name='notes'), + ), + migrations.AddField( + model_name='collectioncategory', + name='notes', + field=models.TextField(blank=True, verbose_name='notes'), + ), + ] diff --git a/src/catalogue/models.py b/src/catalogue/models.py index 18978467..2ceb110b 100644 --- a/src/catalogue/models.py +++ b/src/catalogue/models.py @@ -177,6 +177,7 @@ class Book(WikidataMixin, models.Model): class CollectionCategory(models.Model): name = models.CharField(_("name"), max_length=255) parent = models.ForeignKey('self', models.SET_NULL, related_name='children', null=True, blank=True, verbose_name=_("parent")) + notes = models.TextField(_("notes"), blank=True) class Meta: ordering = ('parent__name', 'name') @@ -194,6 +195,7 @@ class Collection(models.Model): name = models.CharField(_("name"), max_length=255) slug = models.SlugField(max_length=255, unique=True) category = models.ForeignKey(CollectionCategory, models.SET_NULL, null=True, blank=True, verbose_name=_("category")) + notes = models.TextField(_("notes"), blank=True) class Meta: ordering = ('category', 'name') -- 2.20.1