From: Radek Czajka Date: Mon, 19 Dec 2022 14:09:53 +0000 (+0100) Subject: descriptions in catalogue X-Git-Url: https://git.mdrn.pl/redakcja.git/commitdiff_plain/cf5dddce80a2b4fe4d5f8c87cc709050c0efb36e?ds=inline;hp=a1f86966aff87868cbc419b2d1a55d505aead21d descriptions in catalogue --- 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