Merge pull request #592 from Gluejar/fix-preferred-edition

squash the missing edition problem
pull/1/head
Raymond Yee 2016-06-15 11:13:22 -10:00 committed by GitHub
commit 5a22544d11
1 changed files with 7 additions and 2 deletions

View File

@ -1123,8 +1123,12 @@ class Work(models.Model):
@property @property
def googlebooks_id(self): def googlebooks_id(self):
preferred_id=self.preferred_edition.googlebooks_id try:
# note that there's always a preferred edition 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: if preferred_id:
return preferred_id return preferred_id
try: try:
@ -1307,6 +1311,7 @@ class Work(models.Model):
return WasWork.objects.get(was=self.id).work.preferred_edition return WasWork.objects.get(was=self.id).work.preferred_edition
except WasWork.DoesNotExist: except WasWork.DoesNotExist:
#should not happen #should not happen
logger.warning('work {} has no edition'.format(self.id))
return None return None
def last_campaign_status(self): def last_campaign_status(self):