Catch value errors when parsing imported ratings

This commit is contained in:
Mouse Reeve 2023-03-29 20:15:09 -07:00
parent 8cf7c5c392
commit c77436fc12

View file

@ -252,8 +252,11 @@ class ImportItem(models.Model):
@property @property
def rating(self): def rating(self):
"""x/5 star rating for a book""" """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 float(self.normalized_data.get("rating"))
except ValueError:
return None return None
@property @property