handle work/edition concepts in ui

This commit is contained in:
Mouse Reeve
2020-03-30 15:03:21 -07:00
parent f7fb9dde99
commit defd026ed0
6 changed files with 69 additions and 28 deletions

View File

@ -91,7 +91,7 @@ class Book(FedireadsModel):
''' constructs the absolute reference to any db object '''
base_path = 'https://%s' % DOMAIN
model_name = type(self).__name__.lower()
return '%s/%s/%s' % (base_path, model_name, self.openlibrary_key)
return '%s/book/%s' % (base_path, self.openlibrary_key)
def save(self, *args, **kwargs):
''' can't be abstract for query reasons, but you shouldn't USE it '''
@ -112,6 +112,13 @@ class Work(Book):
# library of congress catalog control number
lccn = models.CharField(max_length=255, blank=True, null=True)
@property
def default_edition(self):
ed = Edition.objects.filter(parent_work=self, default=True).first()
if not ed:
ed = Edition.objects.filter(parent_work=self).first()
return ed
class Edition(Book):
''' an edition of a book '''