X-Git-Url: https://git.mdrn.pl/wolnelektury.git/blobdiff_plain/7e113c61d336d677b96ff0ed55a5f81eb2b80d53..084f20588e607aa9ae3ed280b6a2f0349b6a3200:/src/catalogue/models/bookmedia.py diff --git a/src/catalogue/models/bookmedia.py b/src/catalogue/models/bookmedia.py index ec37849d2..9f71364a8 100644 --- a/src/catalogue/models/bookmedia.py +++ b/src/catalogue/models/bookmedia.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # This file is part of Wolnelektury, licensed under GNU Affero GPLv3 or later. # Copyright © Fundacja Nowoczesna Polska. See NOTICE for more information. # @@ -35,7 +34,7 @@ class BookMedia(models.Model): file = models.FileField(_('file'), max_length=600, upload_to=_file_upload_to, storage=OverwriteStorage()) uploaded_at = models.DateTimeField(_('creation date'), auto_now_add=True, editable=False, db_index=True) extra_info = jsonfield.JSONField(_('extra information'), default={}, editable=False) - book = models.ForeignKey('Book', related_name='media') + book = models.ForeignKey('Book', models.CASCADE, related_name='media') source_sha1 = models.CharField(null=True, blank=True, max_length=40, editable=False) def __str__(self): @@ -154,3 +153,6 @@ class BookMedia(models.Model): @property def artist(self): return self.extra_info.get('artist_name', None) + + def file_url(self): + return self.file.url