summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--app/books/admin.py30
-rw-r--r--app/books/migrations/0016_bookhighlight_is_public.py18
-rw-r--r--app/books/models.py1
3 files changed, 48 insertions, 1 deletions
diff --git a/app/books/admin.py b/app/books/admin.py
index f488fe5..f0303a4 100644
--- a/app/books/admin.py
+++ b/app/books/admin.py
@@ -1,17 +1,45 @@
from django.contrib import admin
from .models import Book, BookHighlight
+class BookHighlightInline(admin.StackedInline):
+ model = BookHighlight
+ extra = 0
+ fieldsets = (
+ (None, {
+ 'fields': (
+ 'book',
+ 'body_markdown',
+ 'page',
+ 'is_public',
+ )
+ }),
+ )
+
@admin.register(Book)
class BookAdmin(admin.ModelAdmin):
list_display = ('title', 'admin_thumbnail', 'rating', 'isbn', 'author_name', 'read_date', 'publish_date')
search_fields = ['title', 'body_markdown']
list_filter = ('rating', 'read_date')
+ inlines = [BookHighlightInline,]
class Media:
js = ('next-prev-links.js',)
-
@admin.register(BookHighlight)
class BookHighlightAdmin(admin.ModelAdmin):
list_display = ('book', 'page', 'date_highlighted')
+
+ fieldsets = (
+ (None, {
+ 'fields': (
+ 'book',
+ 'body_markdown',
+ 'is_public',
+ 'page',
+ 'date_highlighted',
+ )
+ }),
+ )
+ class Media:
+ js = ('next-prev-links.js',)
diff --git a/app/books/migrations/0016_bookhighlight_is_public.py b/app/books/migrations/0016_bookhighlight_is_public.py
new file mode 100644
index 0000000..a3ba72b
--- /dev/null
+++ b/app/books/migrations/0016_bookhighlight_is_public.py
@@ -0,0 +1,18 @@
+# Generated by Django 3.1 on 2020-12-20 11:48
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('books', '0015_auto_20201220_1035'),
+ ]
+
+ operations = [
+ migrations.AddField(
+ model_name='bookhighlight',
+ name='is_public',
+ field=models.BooleanField(default=True),
+ ),
+ ]
diff --git a/app/books/models.py b/app/books/models.py
index c25cdc5..5ed972f 100644
--- a/app/books/models.py
+++ b/app/books/models.py
@@ -110,6 +110,7 @@ class BookHighlight(models.Model):
date_highlighted = models.DateTimeField()
body_markdown = models.TextField()
body_html = models.TextField(blank=True)
+ is_public = models.BooleanField(default=True)
class Meta:
ordering = ('-date_highlighted', '-page',)