Skip to content

Commit

Permalink
tweak admin site slightly
Browse files Browse the repository at this point in the history
  • Loading branch information
astynax committed May 26, 2020
1 parent f0424f7 commit c92e64e
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 5 deletions.
7 changes: 5 additions & 2 deletions djaif/book/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
43 changes: 43 additions & 0 deletions djaif/book/migrations/0011_auto_20200526_1529.py
Original file line number Diff line number Diff line change
@@ -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'),
),
]
6 changes: 3 additions & 3 deletions djaif/book/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,20 @@

# 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)


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
Expand Down

0 comments on commit c92e64e

Please sign in to comment.