mirror of
https://github.com/bookwyrm-social/bookwyrm.git
synced 2024-11-25 19:11:09 +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 imagekit.models import ImageSpecField
|
||||||
|
|
||||||
from bookwyrm import activitypub
|
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.preview_images import generate_edition_preview_image_task
|
||||||
from bookwyrm.settings import (
|
from bookwyrm.settings import (
|
||||||
DOMAIN,
|
DOMAIN,
|
||||||
|
@ -321,6 +322,11 @@ class Edition(Book):
|
||||||
serialize_reverse_fields = [("file_links", "fileLinks", "-created_date")]
|
serialize_reverse_fields = [("file_links", "fileLinks", "-created_date")]
|
||||||
deserialize_reverse_fields = [("file_links", "fileLinks")]
|
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):
|
def get_rank(self):
|
||||||
"""calculate how complete the data is on this edition"""
|
"""calculate how complete the data is on this edition"""
|
||||||
rank = 0
|
rank = 0
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
{% if book.isbn_13 %}
|
{% if book.isbn_13 %}
|
||||||
<div class="is-flex is-flex-wrap-wrap">
|
<div class="is-flex is-flex-wrap-wrap">
|
||||||
<dt class="mr-1">{% trans "ISBN:" %}</dt>
|
<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>
|
<div>
|
||||||
<button class="button is-small" data-copywithtooltip data-content-id="isbn_content" data-tooltip-id="isbn_tooltip">
|
<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" %}">
|
<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.activitypub import ActivitypubResponse
|
||||||
from bookwyrm.connectors import connector_manager, ConnectorException
|
from bookwyrm.connectors import connector_manager, ConnectorException
|
||||||
from bookwyrm.connectors.abstract_connector import get_image
|
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.settings import PAGE_LENGTH
|
||||||
from bookwyrm.views.helpers import is_api_request, maybe_redirect_local_path
|
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"],
|
"rating": reviews.aggregate(Avg("rating"))["rating__avg"],
|
||||||
"lists": lists,
|
"lists": lists,
|
||||||
"update_error": kwargs.get("update_error", False),
|
"update_error": kwargs.get("update_error", False),
|
||||||
"hyphenated_isbn13": hyphenator.hyphenate(book.isbn_13),
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if request.user.is_authenticated:
|
if request.user.is_authenticated:
|
||||||
|
|
Loading…
Reference in a new issue