mirror of
https://github.com/bookwyrm-social/bookwyrm.git
synced 2024-12-24 00:50:35 +00:00
Make hyphenated ISBN a property on the book model
This commit is contained in:
parent
0be5cf31dc
commit
83ad45644b
3 changed files with 7 additions and 3 deletions
|
@ -15,6 +15,7 @@ from model_utils.managers import InheritanceManager
|
|||
from imagekit.models import ImageSpecField
|
||||
|
||||
from bookwyrm import activitypub
|
||||
from bookwyrm.isbn.isbn import hyphenator_singleton as hyphenator
|
||||
from bookwyrm.preview_images import generate_edition_preview_image_task
|
||||
from bookwyrm.settings import (
|
||||
DOMAIN,
|
||||
|
@ -321,6 +322,11 @@ class Edition(Book):
|
|||
serialize_reverse_fields = [("file_links", "fileLinks", "-created_date")]
|
||||
deserialize_reverse_fields = [("file_links", "fileLinks")]
|
||||
|
||||
@property
|
||||
def hyphenated_isbn13(self):
|
||||
"""generate the hyphenated version of the ISBN-13"""
|
||||
return hyphenator.hyphenate(self.isbn_13)
|
||||
|
||||
def get_rank(self):
|
||||
"""calculate how complete the data is on this edition"""
|
||||
rank = 0
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
{% if book.isbn_13 %}
|
||||
<div class="is-flex is-flex-wrap-wrap">
|
||||
<dt class="mr-1">{% trans "ISBN:" %}</dt>
|
||||
<dd itemprop="isbn" class="mr-1" id="isbn_content">{{ hyphenated_isbn13 }}</dd>
|
||||
<dd itemprop="isbn" class="mr-1" id="isbn_content">{{ book.hyphenated_isbn13 }}</dd>
|
||||
<div>
|
||||
<button class="button is-small" data-copywithtooltip data-content-id="isbn_content" data-tooltip-id="isbn_tooltip">
|
||||
<span class="icon icon-copy" title="{% trans "Copy ISBN" %}">
|
||||
|
|
|
@ -14,7 +14,6 @@ from bookwyrm import forms, models
|
|||
from bookwyrm.activitypub import ActivitypubResponse
|
||||
from bookwyrm.connectors import connector_manager, ConnectorException
|
||||
from bookwyrm.connectors.abstract_connector import get_image
|
||||
from bookwyrm.isbn.isbn import hyphenator_singleton as hyphenator
|
||||
from bookwyrm.settings import PAGE_LENGTH
|
||||
from bookwyrm.views.helpers import is_api_request, maybe_redirect_local_path
|
||||
|
||||
|
@ -91,7 +90,6 @@ class Book(View):
|
|||
"rating": reviews.aggregate(Avg("rating"))["rating__avg"],
|
||||
"lists": lists,
|
||||
"update_error": kwargs.get("update_error", False),
|
||||
"hyphenated_isbn13": hyphenator.hyphenate(book.isbn_13),
|
||||
}
|
||||
|
||||
if request.user.is_authenticated:
|
||||
|
|
Loading…
Reference in a new issue