From cf5dddce80a2b4fe4d5f8c87cc709050c0efb36e Mon Sep 17 00:00:00 2001 From: Radek Czajka Date: Mon, 19 Dec 2022 15:09:53 +0100 Subject: [PATCH 1/1] descriptions in catalogue --- src/catalogue/admin.py | 25 +++++++++++++++-- ...tion_genre_description_kind_description.py | 28 +++++++++++++++++++ src/catalogue/models.py | 1 + 3 files changed, 51 insertions(+), 3 deletions(-) create mode 100644 src/catalogue/migrations/0044_epoch_description_genre_description_kind_description.py diff --git a/src/catalogue/admin.py b/src/catalogue/admin.py index bfa911fb..48d5dc53 100644 --- a/src/catalogue/admin.py +++ b/src/catalogue/admin.py @@ -361,20 +361,39 @@ admin.site.register(models.Collection, CollectionAdmin) class CategoryAdmin(admin.ModelAdmin): search_fields = ["name"] + def has_description(self, obj): + return bool(obj.description) + has_description.boolean = True + has_description.short_description = 'opis' + @admin.register(models.Epoch) class EpochAdmin(CategoryAdmin): - list_display = ['name', 'adjective_feminine_singular', 'adjective_nonmasculine_plural'] + list_display = [ + 'name', + 'adjective_feminine_singular', + 'adjective_nonmasculine_plural', + 'has_description', + ] @admin.register(models.Genre) class GenreAdmin(CategoryAdmin): - list_display = ['name', 'plural', 'is_epoch_specific'] + list_display = [ + 'name', + 'plural', + 'is_epoch_specific', + 'has_description', + ] @admin.register(models.Kind) class KindAdmin(CategoryAdmin): - list_display = ['name', 'collective_noun'] + list_display = [ + 'name', + 'collective_noun', + 'has_description', + ] diff --git a/src/catalogue/migrations/0044_epoch_description_genre_description_kind_description.py b/src/catalogue/migrations/0044_epoch_description_genre_description_kind_description.py new file mode 100644 index 00000000..2530fa8e --- /dev/null +++ b/src/catalogue/migrations/0044_epoch_description_genre_description_kind_description.py @@ -0,0 +1,28 @@ +# Generated by Django 4.0.6 on 2022-12-19 15:06 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('catalogue', '0043_book_monthly_views_page_book_monthly_views_reader'), + ] + + operations = [ + migrations.AddField( + model_name='epoch', + name='description', + field=models.TextField(blank=True, help_text='for publication', verbose_name='description'), + ), + migrations.AddField( + model_name='genre', + name='description', + field=models.TextField(blank=True, help_text='for publication', verbose_name='description'), + ), + migrations.AddField( + model_name='kind', + name='description', + field=models.TextField(blank=True, help_text='for publication', verbose_name='description'), + ), + ] diff --git a/src/catalogue/models.py b/src/catalogue/models.py index 7a203dd9..8bcf4e00 100644 --- a/src/catalogue/models.py +++ b/src/catalogue/models.py @@ -138,6 +138,7 @@ class NotableBook(OrderableModel): class Category(WikidataModel): name = models.CharField(_("name"), max_length=255) slug = models.SlugField(max_length=255, unique=True) + description = models.TextField(_("description"), blank=True, help_text=_('for publication')) class Meta: abstract = True -- 2.20.1