descriptions in catalogue
authorRadek Czajka <rczajka@rczajka.pl>
Mon, 19 Dec 2022 14:09:53 +0000 (15:09 +0100)
committerRadek Czajka <rczajka@rczajka.pl>
Mon, 19 Dec 2022 14:09:53 +0000 (15:09 +0100)
src/catalogue/admin.py
src/catalogue/migrations/0044_epoch_description_genre_description_kind_description.py [new file with mode: 0644]
src/catalogue/models.py

index bfa911f..48d5dc5 100644 (file)
@@ -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 (file)
index 0000000..2530fa8
--- /dev/null
@@ -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'),
+        ),
+    ]
index 7a203dd..8bcf4e0 100644 (file)
@@ -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