diff --git a/fedireads/books_manager.py b/fedireads/books_manager.py index fcaf65704..915d95cc6 100644 --- a/fedireads/books_manager.py +++ b/fedireads/books_manager.py @@ -8,9 +8,9 @@ from fedireads.connectors.settings import CONNECTORS def get_or_create_book(key): ''' pull up a book record by whatever means possible ''' try: - book = models.Book.objects.get( - openlibrary_key=key - ).select_subclasses() + book = models.Book.objects.select_subclasses().get( + local_key=key + ) return book except models.Book.DoesNotExist: pass diff --git a/fedireads/migrations/0020_auto_20200327_2201.py b/fedireads/migrations/0020_auto_20200327_2236.py similarity index 97% rename from fedireads/migrations/0020_auto_20200327_2201.py rename to fedireads/migrations/0020_auto_20200327_2236.py index 89f45fbed..7292e34cf 100644 --- a/fedireads/migrations/0020_auto_20200327_2201.py +++ b/fedireads/migrations/0020_auto_20200327_2236.py @@ -1,4 +1,4 @@ -# Generated by Django 3.0.3 on 2020-03-27 22:01 +# Generated by Django 3.0.3 on 2020-03-27 22:36 from django.db import migrations, models import django.db.models.deletion diff --git a/fedireads/models/book.py b/fedireads/models/book.py index 94e522b21..9edf59336 100644 --- a/fedireads/models/book.py +++ b/fedireads/models/book.py @@ -1,6 +1,7 @@ ''' database schema for books and shelves ''' from datetime import datetime from django.db import models +from model_utils.managers import InheritanceManager from uuid import uuid4 from fedireads.settings import DOMAIN @@ -66,6 +67,7 @@ class Book(FedireadsModel): ) # TODO: why can't I just call this work???? parent_work = models.ForeignKey('Work', on_delete=models.PROTECT, null=True) + objects = InheritanceManager() @property def absolute_id(self): diff --git a/fedireads/outgoing.py b/fedireads/outgoing.py index 9817c4bc5..f204888b7 100644 --- a/fedireads/outgoing.py +++ b/fedireads/outgoing.py @@ -232,7 +232,7 @@ def handle_tag(user, book, name): def handle_untag(user, book, name): ''' tag a book ''' - book = models.Book.objects.get(openlibrary_key=book) + book = models.Book.objects.get(local_key=book) tag = models.Tag.objects.get(name=name, book=book, user=user) tag_activity = activitypub.get_remove_tag(tag) tag.delete() diff --git a/fedireads/templates/book.html b/fedireads/templates/book.html index 257761818..74777a19b 100644 --- a/fedireads/templates/book.html +++ b/fedireads/templates/book.html @@ -5,7 +5,7 @@
{{ book.title }}by {% include 'snippets/authors.html' with book=book %}
Edition of {{ book.parent_work.title }}
{% endif %} + {% if book.parent_work %}Edition of {{ book.parent_work.title }}
{% endif %}- {{ book.title }} + {{ book.title }}
by {% include 'snippets/authors.html' with book=book %} diff --git a/fedireads/templates/snippets/create_status.html b/fedireads/templates/snippets/create_status.html index 8206e768f..bd3efbcf7 100644 --- a/fedireads/templates/snippets/create_status.html +++ b/fedireads/templates/snippets/create_status.html @@ -4,7 +4,7 @@