X-Git-Url: https://git.mdrn.pl/audio.git/blobdiff_plain/d34100c7ed69f83e552ec589fd0c353129165452..811a5e0c009907cba39afcd954b3644f46adcec7:/src/archive/models.py diff --git a/src/archive/models.py b/src/archive/models.py index 869641c..1fc033b 100644 --- a/src/archive/models.py +++ b/src/archive/models.py @@ -1,9 +1,11 @@ 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 _ @@ -47,6 +49,14 @@ class Project(models.Model): " 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?