mirror of
https://github.com/bookwyrm-social/bookwyrm.git
synced 2024-11-30 05:21:08 +00:00
Fixes ranks and normalizes isbns
This commit is contained in:
parent
7853610a20
commit
d1b5f3b6f0
1 changed files with 8 additions and 1 deletions
|
@ -216,7 +216,10 @@ class Edition(Book):
|
||||||
# is it in the instance's preferred language?
|
# is it in the instance's preferred language?
|
||||||
rank += int(bool(DEFAULT_LANGUAGE in self.languages))
|
rank += int(bool(DEFAULT_LANGUAGE in self.languages))
|
||||||
# prefer print editions
|
# prefer print editions
|
||||||
rank += int(bool(self.physical_format.lower() in ["paperback", "hardcover"]))
|
if self.physical_format:
|
||||||
|
rank += int(
|
||||||
|
bool(self.physical_format.lower() in ["paperback", "hardcover"])
|
||||||
|
)
|
||||||
|
|
||||||
# does it have metadata?
|
# does it have metadata?
|
||||||
rank += int(bool(self.isbn_13))
|
rank += int(bool(self.isbn_13))
|
||||||
|
@ -236,6 +239,10 @@ class Edition(Book):
|
||||||
if self.isbn_10 and not self.isbn_13:
|
if self.isbn_10 and not self.isbn_13:
|
||||||
self.isbn_13 = isbn_10_to_13(self.isbn_10)
|
self.isbn_13 = isbn_10_to_13(self.isbn_10)
|
||||||
|
|
||||||
|
# normalize isbn format
|
||||||
|
self.isbn_10 = re.sub(r"[^0-9X]", "", self.isbn_10)
|
||||||
|
self.isbn_13 = re.sub(r"[^0-9X]", "", self.isbn_13)
|
||||||
|
|
||||||
# set rank
|
# set rank
|
||||||
self.edition_rank = self.get_rank()
|
self.edition_rank = self.get_rank()
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue