fnp
/
wolnelektury.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
To get from Yokohama to San Francisco, keep going east.
[wolnelektury.git]
/
src
/
catalogue
/
utils.py
diff --git
a/src/catalogue/utils.py
b/src/catalogue/utils.py
index
d056579
..
916fd70
100644
(file)
--- a/
src/catalogue/utils.py
+++ b/
src/catalogue/utils.py
@@
-11,8
+11,10
@@
from collections import defaultdict
from errno import EEXIST, ENOENT
from fcntl import flock, LOCK_EX
from os import mkdir, path, unlink
from errno import EEXIST, ENOENT
from fcntl import flock, LOCK_EX
from os import mkdir, path, unlink
+from urllib.parse import urljoin
from zipfile import ZipFile
from zipfile import ZipFile
+from django.apps import apps
from django.conf import settings
from django.core.files.storage import DefaultStorage
from django.core.files.uploadedfile import UploadedFile
from django.conf import settings
from django.core.files.storage import DefaultStorage
from django.core.files.uploadedfile import UploadedFile
@@
-303,13
+305,23
@@
def delete_from_cache_by_language(cache, key_template):
def gallery_path(slug):
def gallery_path(slug):
- return os.path.join(settings.MEDIA_ROOT, settings.IMAGE_DIR, slug)
+ return os.path.join(settings.MEDIA_ROOT, settings.IMAGE_DIR, slug)
+ '/'
def gallery_url(slug):
return '%s%s%s/' % (settings.MEDIA_URL, settings.IMAGE_DIR, slug)
def gallery_url(slug):
return '%s%s%s/' % (settings.MEDIA_URL, settings.IMAGE_DIR, slug)
+def absolute_url(url):
+ Site = apps.get_model('sites', 'Site')
+ site = Site.objects.get_current()
+ base_url = '%s://%s' % (
+ 'https' if settings.SESSION_COOKIE_SECURE else 'http',
+ site.domain
+ )
+ return urljoin(base_url, url)
+
+
def get_mp3_length(path):
from mutagen.mp3 import MP3
return int(MP3(path).info.length)
def get_mp3_length(path):
from mutagen.mp3 import MP3
return int(MP3(path).info.length)