From 8cb502d5b98f4445e06bcb22a39eafde4baf8cf7 Mon Sep 17 00:00:00 2001 From: eric Date: Fri, 10 Jun 2016 16:30:03 -0400 Subject: [PATCH] squash the missing edition problem --- core/models.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/core/models.py b/core/models.py index 5fb936df..53f77178 100755 --- a/core/models.py +++ b/core/models.py @@ -1123,8 +1123,12 @@ class Work(models.Model): @property def googlebooks_id(self): - preferred_id=self.preferred_edition.googlebooks_id - # note that there's always a preferred edition + try: + preferred_id=self.preferred_edition.googlebooks_id + # note that there should always be a preferred edition + except AttributeError: + # this work has no edition. + return '' if preferred_id: return preferred_id try: @@ -1307,6 +1311,7 @@ class Work(models.Model): return WasWork.objects.get(was=self.id).work.preferred_edition except WasWork.DoesNotExist: #should not happen + logger.warning('work {} has no edition'.format(self.id)) return None def last_campaign_status(self):