mirror of
https://github.com/bookwyrm-social/bookwyrm.git
synced 2024-10-31 22:19:00 +00:00
Merge pull request #2770 from bookwyrm-social/import-rating-parser
Catch value errors when parsing imported ratings
This commit is contained in:
commit
ac48457748
2 changed files with 6 additions and 3 deletions
|
@ -19,7 +19,7 @@ class LibrarythingImporter(Importer):
|
|||
normalized = {k: remove_brackets(entry.get(v)) for k, v in mappings.items()}
|
||||
isbn_13 = normalized.get("isbn_13")
|
||||
isbn_13 = isbn_13.split(", ") if isbn_13 else []
|
||||
normalized["isbn_13"] = isbn_13[1] if len(isbn_13) > 0 else None
|
||||
normalized["isbn_13"] = isbn_13[1] if len(isbn_13) > 1 else None
|
||||
return normalized
|
||||
|
||||
def get_shelf(self, normalized_row):
|
||||
|
|
|
@ -252,9 +252,12 @@ class ImportItem(models.Model):
|
|||
@property
|
||||
def rating(self):
|
||||
"""x/5 star rating for a book"""
|
||||
if self.normalized_data.get("rating"):
|
||||
if not self.normalized_data.get("rating"):
|
||||
return None
|
||||
try:
|
||||
return float(self.normalized_data.get("rating"))
|
||||
return None
|
||||
except ValueError:
|
||||
return None
|
||||
|
||||
@property
|
||||
def date_added(self):
|
||||
|
|
Loading…
Reference in a new issue