import io
import json
import os.path
+from urllib.parse import urljoin
from django.db import models
from time import sleep
+from django.contrib.sites.models import Site
from django.utils.functional import cached_property
from django.utils.timezone import now
from django.utils.translation import gettext_lazy as _
" finansowanego przez %s" % self.sponsors if self.sponsors else "",
)
+ def get_icon_url(self):
+ if not self.icon:
+ return ''
+ return urljoin(
+ 'https://' + Site.objects.get_current().domain,
+ self.icon.url
+ )
+
def source_upload_to(intance, filename):
return os.path.join(FILES_SAVE_PATH, filename) # FIXME: what about really long file names?
'project': {
'description': audiobook.project.get_description(),
- 'icon': audiobook.project.icon.url,
+ 'icon': audiobook.project.get_icon_url(),
}
}
with open(path, 'rb') as f: