mirror of
https://github.com/bookwyrm-social/bookwyrm.git
synced 2024-11-15 13:24:04 +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?
|
||||
rank += int(bool(DEFAULT_LANGUAGE in self.languages))
|
||||
# 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?
|
||||
rank += int(bool(self.isbn_13))
|
||||
|
@ -236,6 +239,10 @@ class Edition(Book):
|
|||
if self.isbn_10 and not self.isbn_13:
|
||||
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
|
||||
self.edition_rank = self.get_rank()
|
||||
|
||||
|
|
Loading…
Reference in a new issue