From c92e64e6a6d9621ea1dec8a7dea9e07d85182cac Mon Sep 17 00:00:00 2001 From: Aleksei Pirogov Date: Tue, 26 May 2020 18:31:08 +0300 Subject: [PATCH] tweak admin site slightly --- djaif/book/admin.py | 7 ++- .../migrations/0011_auto_20200526_1529.py | 43 +++++++++++++++++++ djaif/book/models.py | 6 +-- 3 files changed, 51 insertions(+), 5 deletions(-) create mode 100644 djaif/book/migrations/0011_auto_20200526_1529.py diff --git a/djaif/book/admin.py b/djaif/book/admin.py index bc7f887..0a8c93b 100644 --- a/djaif/book/admin.py +++ b/djaif/book/admin.py @@ -2,8 +2,11 @@ from djaif.book import models +class Admin(admin.ModelAdmin): + filter_horizontal = ('items',) + admin.site.register(models.Book) -admin.site.register(models.BookPage) -admin.site.register(models.PageLink) +admin.site.register(models.BookPage, Admin) +admin.site.register(models.PageLink, Admin) admin.site.register(models.BookProgress) admin.site.register(models.Item) diff --git a/djaif/book/migrations/0011_auto_20200526_1529.py b/djaif/book/migrations/0011_auto_20200526_1529.py new file mode 100644 index 0000000..e8b2a3b --- /dev/null +++ b/djaif/book/migrations/0011_auto_20200526_1529.py @@ -0,0 +1,43 @@ +# Generated by Django 3.0.5 on 2020-05-26 15:29 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('book', '0010_pagelink_items'), + ] + + operations = [ + migrations.AlterField( + model_name='book', + name='cover_art', + field=models.ImageField(blank=True, null=True, upload_to=''), + ), + migrations.AlterField( + model_name='book', + name='title', + field=models.CharField(max_length=100, unique=True), + ), + migrations.AlterField( + model_name='bookpage', + name='items', + field=models.ManyToManyField(blank=True, to='book.Item'), + ), + migrations.AlterField( + model_name='bookpage', + name='title', + field=models.CharField(max_length=100), + ), + migrations.AlterField( + model_name='bookprogress', + name='items', + field=models.ManyToManyField(blank=True, to='book.Item'), + ), + migrations.AlterField( + model_name='pagelink', + name='items', + field=models.ManyToManyField(blank=True, to='book.Item'), + ), + ] diff --git a/djaif/book/models.py b/djaif/book/models.py index 984aa65..eaaf317 100644 --- a/djaif/book/models.py +++ b/djaif/book/models.py @@ -4,12 +4,12 @@ # Create your models here. class Book(models.Model): - title = models.TextField(name='title', unique=True) + title = models.CharField(name='title', max_length=100, unique=True) first_page = models.ForeignKey( 'BookPage', null=True, on_delete=models.SET_NULL, related_name='first_name', ) - cover_art = models.ImageField(null=True) + cover_art = models.ImageField(null=True, blank=True) def __str__(self): return '{self.title} ({self.id})'.format(self=self) @@ -17,7 +17,7 @@ def __str__(self): class BookPage(models.Model): book = models.ForeignKey(Book, on_delete=models.CASCADE) - title = models.TextField(name='title') + title = models.CharField(name='title', max_length=100) body = models.TextField(name='body') items = models.ManyToManyField('book.Item', blank=True) # noqa: WPS110