From f324dab1ea7d6b9fa6a0f7a70369a0e5bcfa34e2 Mon Sep 17 00:00:00 2001 From: Radek Czajka Date: Mon, 29 Mar 2021 12:16:08 +0200 Subject: [PATCH 1/1] Always use absolute base url for ebooks with images. --- src/catalogue/fields.py | 10 ++++----- src/catalogue/locale/de/LC_MESSAGES/django.po | 22 +++++++++---------- src/catalogue/locale/en/LC_MESSAGES/django.po | 22 +++++++++---------- src/catalogue/locale/es/LC_MESSAGES/django.po | 22 +++++++++---------- src/catalogue/locale/fr/LC_MESSAGES/django.po | 22 +++++++++---------- src/catalogue/locale/it/LC_MESSAGES/django.po | 22 +++++++++---------- src/catalogue/locale/lt/LC_MESSAGES/django.po | 22 +++++++++---------- src/catalogue/locale/pl/LC_MESSAGES/django.po | 22 +++++++++---------- src/catalogue/locale/ru/LC_MESSAGES/django.po | 22 +++++++++---------- src/catalogue/locale/uk/LC_MESSAGES/django.po | 22 +++++++++---------- src/catalogue/tasks.py | 4 ++-- src/catalogue/utils.py | 12 ++++++++++ 12 files changed, 118 insertions(+), 106 deletions(-) diff --git a/src/catalogue/fields.py b/src/catalogue/fields.py index 79fe67e38..4c832fd13 100644 --- a/src/catalogue/fields.py +++ b/src/catalogue/fields.py @@ -8,7 +8,7 @@ from django.db import models from django.db.models.fields.files import FieldFile from catalogue import app_settings from catalogue.constants import LANGUAGES_3TO2, EBOOK_FORMATS_WITH_CHILDREN, EBOOK_FORMATS_WITHOUT_CHILDREN -from catalogue.utils import remove_zip, truncate_html_words, gallery_path, gallery_url +from catalogue.utils import absolute_url, remove_zip, truncate_html_words, gallery_path, gallery_url from celery.task import Task, task from celery.utils.log import get_task_logger from waiter.utils import clear_cache @@ -191,7 +191,7 @@ class BuildPdf(BuildEbook): def transform(wldoc, fieldfile): return wldoc.as_pdf( morefloats=settings.LIBRARIAN_PDF_MOREFLOATS, cover=True, - base_url=gallery_url(wldoc.book_info.url.slug), customizations=['notoc']) + base_url=absolute_url(gallery_url(wldoc.book_info.url.slug)), customizations=['notoc']) def build(self, fieldfile): BuildEbook.build(self, fieldfile) @@ -203,7 +203,7 @@ class BuildPdf(BuildEbook): class BuildEpub(BuildEbook): @staticmethod def transform(wldoc, fieldfile): - return wldoc.as_epub(cover=True, base_url=gallery_url(wldoc.book_info.url.slug)) + return wldoc.as_epub(cover=True, base_url=absolute_url(gallery_url(wldoc.book_info.url.slug))) @BuildEbook.register('mobi') @@ -211,7 +211,7 @@ class BuildEpub(BuildEbook): class BuildMobi(BuildEbook): @staticmethod def transform(wldoc, fieldfile): - return wldoc.as_mobi(cover=True, base_url=gallery_url(wldoc.book_info.url.slug)) + return wldoc.as_mobi(cover=True, base_url=absolute_url(gallery_url(wldoc.book_info.url.slug))) @BuildEbook.register('html') @@ -317,7 +317,7 @@ class BuildHtml(BuildEbook): slug = url_elem.text.rstrip('/').rsplit('/', 1)[1] gal_url = gallery_url(slug=slug) gal_path = gallery_path(slug=slug) - return wldoc.as_html(gallery_path=gal_path, gallery_url=gal_url, base_url=gal_url) + return wldoc.as_html(gallery_path=gal_path, gallery_url=gal_url, base_url=absolute_url(gal_url)) class BuildCover(BuildEbook): diff --git a/src/catalogue/locale/de/LC_MESSAGES/django.po b/src/catalogue/locale/de/LC_MESSAGES/django.po index c3b876faf..b6944d64a 100644 --- a/src/catalogue/locale/de/LC_MESSAGES/django.po +++ b/src/catalogue/locale/de/LC_MESSAGES/django.po @@ -214,7 +214,7 @@ msgstr "Erstellungsdatum" msgid "parent number" msgstr "Elternnummer" -#: catalogue/models/book.py:69 catalogue/models/bookmedia.py:41 +#: catalogue/models/book.py:69 catalogue/models/bookmedia.py:43 msgid "extra information" msgstr "zusätzliche Informationen" @@ -313,7 +313,7 @@ msgstr "" msgid "file" msgstr "XML-Datei" -#: catalogue/models/bookmedia.py:50 catalogue/models/bookmedia.py:51 +#: catalogue/models/bookmedia.py:52 catalogue/models/bookmedia.py:53 msgid "book media" msgstr "book media" @@ -576,7 +576,7 @@ msgstr "Sprachenkode" msgid "Read online" msgstr "Online lesen" -#: catalogue/templates/catalogue/book_short.html:123 +#: catalogue/templates/catalogue/book_short.html:115 msgid "" "Cena książki w druku cyfrowym jest zależna od liczby stron.
Przed zakupem " "upewnij się, że cena druku na żądanie jest dla Ciebie odpowiednia." @@ -584,24 +584,24 @@ msgid "" "bezpłatnie." msgstr "" -#: catalogue/templates/catalogue/book_short.html:123 +#: catalogue/templates/catalogue/book_short.html:115 msgid "Print on demand –" msgstr "" -#: catalogue/templates/catalogue/book_short.html:128 +#: catalogue/templates/catalogue/book_short.html:120 #: catalogue/templates/catalogue/custom_pdf_form.html:18 catalogue/views.py:404 msgid "Download" msgstr "Herunterladen" -#: catalogue/templates/catalogue/book_short.html:142 +#: catalogue/templates/catalogue/book_short.html:134 msgid "more" msgstr "" -#: catalogue/templates/catalogue/book_short.html:153 +#: catalogue/templates/catalogue/book_short.html:145 msgid "less" msgstr "" -#: catalogue/templates/catalogue/book_short.html:161 +#: catalogue/templates/catalogue/book_short.html:153 msgid "For now this work is only available for our subscribers." msgstr "" @@ -888,15 +888,15 @@ msgstr "Künstler" msgid "director:" msgstr "Regisseur" -#: catalogue/templates/catalogue/snippets/jplayer.html:61 +#: catalogue/templates/catalogue/snippets/jplayer.html:64 msgid "previous" msgstr "" -#: catalogue/templates/catalogue/snippets/jplayer.html:62 +#: catalogue/templates/catalogue/snippets/jplayer.html:65 msgid "Part" msgstr "" -#: catalogue/templates/catalogue/snippets/jplayer.html:63 +#: catalogue/templates/catalogue/snippets/jplayer.html:66 msgid "next" msgstr "" diff --git a/src/catalogue/locale/en/LC_MESSAGES/django.po b/src/catalogue/locale/en/LC_MESSAGES/django.po index ba81501f2..b72edd486 100644 --- a/src/catalogue/locale/en/LC_MESSAGES/django.po +++ b/src/catalogue/locale/en/LC_MESSAGES/django.po @@ -214,7 +214,7 @@ msgstr "creation date" msgid "parent number" msgstr "Parent number" -#: catalogue/models/book.py:69 catalogue/models/bookmedia.py:41 +#: catalogue/models/book.py:69 catalogue/models/bookmedia.py:43 msgid "extra information" msgstr "Additional information" @@ -312,7 +312,7 @@ msgstr "" msgid "file" msgstr "XML file" -#: catalogue/models/bookmedia.py:50 catalogue/models/bookmedia.py:51 +#: catalogue/models/bookmedia.py:52 catalogue/models/bookmedia.py:53 msgid "book media" msgstr "book media" @@ -578,7 +578,7 @@ msgstr "language code" msgid "Read online" msgstr "Read online" -#: catalogue/templates/catalogue/book_short.html:123 +#: catalogue/templates/catalogue/book_short.html:115 msgid "" "Cena książki w druku cyfrowym jest zależna od liczby stron.
Przed zakupem " "upewnij się, że cena druku na żądanie jest dla Ciebie odpowiednia." @@ -586,24 +586,24 @@ msgid "" "bezpłatnie." msgstr "" -#: catalogue/templates/catalogue/book_short.html:123 +#: catalogue/templates/catalogue/book_short.html:115 msgid "Print on demand –" msgstr "" -#: catalogue/templates/catalogue/book_short.html:128 +#: catalogue/templates/catalogue/book_short.html:120 #: catalogue/templates/catalogue/custom_pdf_form.html:18 catalogue/views.py:404 msgid "Download" msgstr "Download" -#: catalogue/templates/catalogue/book_short.html:142 +#: catalogue/templates/catalogue/book_short.html:134 msgid "more" msgstr "" -#: catalogue/templates/catalogue/book_short.html:153 +#: catalogue/templates/catalogue/book_short.html:145 msgid "less" msgstr "" -#: catalogue/templates/catalogue/book_short.html:161 +#: catalogue/templates/catalogue/book_short.html:153 msgid "For now this work is only available for our subscribers." msgstr "" @@ -889,15 +889,15 @@ msgstr "Reader" msgid "director:" msgstr "Director" -#: catalogue/templates/catalogue/snippets/jplayer.html:61 +#: catalogue/templates/catalogue/snippets/jplayer.html:64 msgid "previous" msgstr "" -#: catalogue/templates/catalogue/snippets/jplayer.html:62 +#: catalogue/templates/catalogue/snippets/jplayer.html:65 msgid "Part" msgstr "" -#: catalogue/templates/catalogue/snippets/jplayer.html:63 +#: catalogue/templates/catalogue/snippets/jplayer.html:66 msgid "next" msgstr "" diff --git a/src/catalogue/locale/es/LC_MESSAGES/django.po b/src/catalogue/locale/es/LC_MESSAGES/django.po index 4e80a3dce..02cc16bd9 100644 --- a/src/catalogue/locale/es/LC_MESSAGES/django.po +++ b/src/catalogue/locale/es/LC_MESSAGES/django.po @@ -214,7 +214,7 @@ msgstr "fecha de creación" msgid "parent number" msgstr "cifra matriz" -#: catalogue/models/book.py:69 catalogue/models/bookmedia.py:41 +#: catalogue/models/book.py:69 catalogue/models/bookmedia.py:43 msgid "extra information" msgstr "información adicional" @@ -312,7 +312,7 @@ msgstr "" msgid "file" msgstr "archivo" -#: catalogue/models/bookmedia.py:50 catalogue/models/bookmedia.py:51 +#: catalogue/models/bookmedia.py:52 catalogue/models/bookmedia.py:53 msgid "book media" msgstr "los medios de el libro" @@ -583,7 +583,7 @@ msgstr "código de idioma" msgid "Read online" msgstr "Leer en línea" -#: catalogue/templates/catalogue/book_short.html:123 +#: catalogue/templates/catalogue/book_short.html:115 msgid "" "Cena książki w druku cyfrowym jest zależna od liczby stron.
Przed zakupem " "upewnij się, że cena druku na żądanie jest dla Ciebie odpowiednia." @@ -591,24 +591,24 @@ msgid "" "bezpłatnie." msgstr "" -#: catalogue/templates/catalogue/book_short.html:123 +#: catalogue/templates/catalogue/book_short.html:115 msgid "Print on demand –" msgstr "" -#: catalogue/templates/catalogue/book_short.html:128 +#: catalogue/templates/catalogue/book_short.html:120 #: catalogue/templates/catalogue/custom_pdf_form.html:18 catalogue/views.py:404 msgid "Download" msgstr "Descargar" -#: catalogue/templates/catalogue/book_short.html:142 +#: catalogue/templates/catalogue/book_short.html:134 msgid "more" msgstr "" -#: catalogue/templates/catalogue/book_short.html:153 +#: catalogue/templates/catalogue/book_short.html:145 msgid "less" msgstr "" -#: catalogue/templates/catalogue/book_short.html:161 +#: catalogue/templates/catalogue/book_short.html:153 msgid "For now this work is only available for our subscribers." msgstr "" @@ -900,15 +900,15 @@ msgstr "Artista" msgid "director:" msgstr "Director" -#: catalogue/templates/catalogue/snippets/jplayer.html:61 +#: catalogue/templates/catalogue/snippets/jplayer.html:64 msgid "previous" msgstr "" -#: catalogue/templates/catalogue/snippets/jplayer.html:62 +#: catalogue/templates/catalogue/snippets/jplayer.html:65 msgid "Part" msgstr "" -#: catalogue/templates/catalogue/snippets/jplayer.html:63 +#: catalogue/templates/catalogue/snippets/jplayer.html:66 msgid "next" msgstr "" diff --git a/src/catalogue/locale/fr/LC_MESSAGES/django.po b/src/catalogue/locale/fr/LC_MESSAGES/django.po index 77752023a..e1cdb4074 100644 --- a/src/catalogue/locale/fr/LC_MESSAGES/django.po +++ b/src/catalogue/locale/fr/LC_MESSAGES/django.po @@ -213,7 +213,7 @@ msgstr "date de création" msgid "parent number" msgstr "nombre de parent" -#: catalogue/models/book.py:69 catalogue/models/bookmedia.py:41 +#: catalogue/models/book.py:69 catalogue/models/bookmedia.py:43 msgid "extra information" msgstr "information supplémentaire" @@ -311,7 +311,7 @@ msgstr "" msgid "file" msgstr "fichier" -#: catalogue/models/bookmedia.py:50 catalogue/models/bookmedia.py:51 +#: catalogue/models/bookmedia.py:52 catalogue/models/bookmedia.py:53 msgid "book media" msgstr "book media" @@ -577,7 +577,7 @@ msgstr "code de langue" msgid "Read online" msgstr "Lire en ligne" -#: catalogue/templates/catalogue/book_short.html:123 +#: catalogue/templates/catalogue/book_short.html:115 msgid "" "Cena książki w druku cyfrowym jest zależna od liczby stron.
Przed zakupem " "upewnij się, że cena druku na żądanie jest dla Ciebie odpowiednia." @@ -585,24 +585,24 @@ msgid "" "bezpłatnie." msgstr "" -#: catalogue/templates/catalogue/book_short.html:123 +#: catalogue/templates/catalogue/book_short.html:115 msgid "Print on demand –" msgstr "" -#: catalogue/templates/catalogue/book_short.html:128 +#: catalogue/templates/catalogue/book_short.html:120 #: catalogue/templates/catalogue/custom_pdf_form.html:18 catalogue/views.py:404 msgid "Download" msgstr "Téléchargez" -#: catalogue/templates/catalogue/book_short.html:142 +#: catalogue/templates/catalogue/book_short.html:134 msgid "more" msgstr "" -#: catalogue/templates/catalogue/book_short.html:153 +#: catalogue/templates/catalogue/book_short.html:145 msgid "less" msgstr "" -#: catalogue/templates/catalogue/book_short.html:161 +#: catalogue/templates/catalogue/book_short.html:153 msgid "For now this work is only available for our subscribers." msgstr "" @@ -893,15 +893,15 @@ msgstr "Artiste" msgid "director:" msgstr "Metteur en scène" -#: catalogue/templates/catalogue/snippets/jplayer.html:61 +#: catalogue/templates/catalogue/snippets/jplayer.html:64 msgid "previous" msgstr "" -#: catalogue/templates/catalogue/snippets/jplayer.html:62 +#: catalogue/templates/catalogue/snippets/jplayer.html:65 msgid "Part" msgstr "" -#: catalogue/templates/catalogue/snippets/jplayer.html:63 +#: catalogue/templates/catalogue/snippets/jplayer.html:66 msgid "next" msgstr "" diff --git a/src/catalogue/locale/it/LC_MESSAGES/django.po b/src/catalogue/locale/it/LC_MESSAGES/django.po index 2de547327..e91c15757 100644 --- a/src/catalogue/locale/it/LC_MESSAGES/django.po +++ b/src/catalogue/locale/it/LC_MESSAGES/django.po @@ -214,7 +214,7 @@ msgstr "data di creazione" msgid "parent number" msgstr "numero del genitore" -#: catalogue/models/book.py:69 catalogue/models/bookmedia.py:41 +#: catalogue/models/book.py:69 catalogue/models/bookmedia.py:43 msgid "extra information" msgstr " ulteriori informazioni" @@ -312,7 +312,7 @@ msgstr "" msgid "file" msgstr "file" -#: catalogue/models/bookmedia.py:50 catalogue/models/bookmedia.py:51 +#: catalogue/models/bookmedia.py:52 catalogue/models/bookmedia.py:53 msgid "book media" msgstr "book media" @@ -580,7 +580,7 @@ msgstr "codice della lingua" msgid "Read online" msgstr "Leggi online" -#: catalogue/templates/catalogue/book_short.html:123 +#: catalogue/templates/catalogue/book_short.html:115 msgid "" "Cena książki w druku cyfrowym jest zależna od liczby stron.
Przed zakupem " "upewnij się, że cena druku na żądanie jest dla Ciebie odpowiednia." @@ -588,24 +588,24 @@ msgid "" "bezpłatnie." msgstr "" -#: catalogue/templates/catalogue/book_short.html:123 +#: catalogue/templates/catalogue/book_short.html:115 msgid "Print on demand –" msgstr "" -#: catalogue/templates/catalogue/book_short.html:128 +#: catalogue/templates/catalogue/book_short.html:120 #: catalogue/templates/catalogue/custom_pdf_form.html:18 catalogue/views.py:404 msgid "Download" msgstr "Scarica" -#: catalogue/templates/catalogue/book_short.html:142 +#: catalogue/templates/catalogue/book_short.html:134 msgid "more" msgstr "" -#: catalogue/templates/catalogue/book_short.html:153 +#: catalogue/templates/catalogue/book_short.html:145 msgid "less" msgstr "" -#: catalogue/templates/catalogue/book_short.html:161 +#: catalogue/templates/catalogue/book_short.html:153 msgid "For now this work is only available for our subscribers." msgstr "" @@ -896,15 +896,15 @@ msgstr "Artista" msgid "director:" msgstr "Direttore" -#: catalogue/templates/catalogue/snippets/jplayer.html:61 +#: catalogue/templates/catalogue/snippets/jplayer.html:64 msgid "previous" msgstr "" -#: catalogue/templates/catalogue/snippets/jplayer.html:62 +#: catalogue/templates/catalogue/snippets/jplayer.html:65 msgid "Part" msgstr "" -#: catalogue/templates/catalogue/snippets/jplayer.html:63 +#: catalogue/templates/catalogue/snippets/jplayer.html:66 msgid "next" msgstr "" diff --git a/src/catalogue/locale/lt/LC_MESSAGES/django.po b/src/catalogue/locale/lt/LC_MESSAGES/django.po index 37e5f4961..617465618 100644 --- a/src/catalogue/locale/lt/LC_MESSAGES/django.po +++ b/src/catalogue/locale/lt/LC_MESSAGES/django.po @@ -215,7 +215,7 @@ msgstr "sukūrimo data" msgid "parent number" msgstr "pirminis numeris" -#: catalogue/models/book.py:69 catalogue/models/bookmedia.py:41 +#: catalogue/models/book.py:69 catalogue/models/bookmedia.py:43 msgid "extra information" msgstr "papildomos informacijos" @@ -313,7 +313,7 @@ msgstr "" msgid "file" msgstr "failas " -#: catalogue/models/bookmedia.py:50 catalogue/models/bookmedia.py:51 +#: catalogue/models/bookmedia.py:52 catalogue/models/bookmedia.py:53 msgid "book media" msgstr "book media" @@ -580,7 +580,7 @@ msgstr "kalbos kodas" msgid "Read online" msgstr "Skaityti online" -#: catalogue/templates/catalogue/book_short.html:123 +#: catalogue/templates/catalogue/book_short.html:115 msgid "" "Cena książki w druku cyfrowym jest zależna od liczby stron.
Przed zakupem " "upewnij się, że cena druku na żądanie jest dla Ciebie odpowiednia." @@ -588,24 +588,24 @@ msgid "" "bezpłatnie." msgstr "" -#: catalogue/templates/catalogue/book_short.html:123 +#: catalogue/templates/catalogue/book_short.html:115 msgid "Print on demand –" msgstr "" -#: catalogue/templates/catalogue/book_short.html:128 +#: catalogue/templates/catalogue/book_short.html:120 #: catalogue/templates/catalogue/custom_pdf_form.html:18 catalogue/views.py:404 msgid "Download" msgstr "Atsisiųsti" -#: catalogue/templates/catalogue/book_short.html:142 +#: catalogue/templates/catalogue/book_short.html:134 msgid "more" msgstr "" -#: catalogue/templates/catalogue/book_short.html:153 +#: catalogue/templates/catalogue/book_short.html:145 msgid "less" msgstr "" -#: catalogue/templates/catalogue/book_short.html:161 +#: catalogue/templates/catalogue/book_short.html:153 msgid "For now this work is only available for our subscribers." msgstr "" @@ -894,15 +894,15 @@ msgstr "Artistas" msgid "director:" msgstr "Režisierus" -#: catalogue/templates/catalogue/snippets/jplayer.html:61 +#: catalogue/templates/catalogue/snippets/jplayer.html:64 msgid "previous" msgstr "" -#: catalogue/templates/catalogue/snippets/jplayer.html:62 +#: catalogue/templates/catalogue/snippets/jplayer.html:65 msgid "Part" msgstr "" -#: catalogue/templates/catalogue/snippets/jplayer.html:63 +#: catalogue/templates/catalogue/snippets/jplayer.html:66 msgid "next" msgstr "" diff --git a/src/catalogue/locale/pl/LC_MESSAGES/django.po b/src/catalogue/locale/pl/LC_MESSAGES/django.po index 29a62a9dc..3dc983240 100644 --- a/src/catalogue/locale/pl/LC_MESSAGES/django.po +++ b/src/catalogue/locale/pl/LC_MESSAGES/django.po @@ -187,7 +187,7 @@ msgstr "data modyfikacji" msgid "parent number" msgstr "numer rodzica" -#: catalogue/models/book.py:69 catalogue/models/bookmedia.py:41 +#: catalogue/models/book.py:69 catalogue/models/bookmedia.py:43 msgid "extra information" msgstr "dodatkowe informacje" @@ -283,7 +283,7 @@ msgstr "indeks" msgid "file" msgstr "plik" -#: catalogue/models/bookmedia.py:50 catalogue/models/bookmedia.py:51 +#: catalogue/models/bookmedia.py:52 catalogue/models/bookmedia.py:53 msgid "book media" msgstr "media książki" @@ -524,7 +524,7 @@ msgstr "Język" msgid "Read online" msgstr "Czytaj online" -#: catalogue/templates/catalogue/book_short.html:123 +#: catalogue/templates/catalogue/book_short.html:115 msgid "" "Cena książki w druku cyfrowym jest zależna od liczby stron.
Przed zakupem " "upewnij się, że cena druku na żądanie jest dla Ciebie odpowiednia." @@ -532,24 +532,24 @@ msgid "" "bezpłatnie." msgstr "" -#: catalogue/templates/catalogue/book_short.html:123 +#: catalogue/templates/catalogue/book_short.html:115 msgid "Print on demand –" msgstr "Druk na żądanie z" -#: catalogue/templates/catalogue/book_short.html:128 +#: catalogue/templates/catalogue/book_short.html:120 #: catalogue/templates/catalogue/custom_pdf_form.html:18 catalogue/views.py:404 msgid "Download" msgstr "Pobierz" -#: catalogue/templates/catalogue/book_short.html:142 +#: catalogue/templates/catalogue/book_short.html:134 msgid "more" msgstr "więcej" -#: catalogue/templates/catalogue/book_short.html:153 +#: catalogue/templates/catalogue/book_short.html:145 msgid "less" msgstr "mniej" -#: catalogue/templates/catalogue/book_short.html:161 +#: catalogue/templates/catalogue/book_short.html:153 msgid "For now this work is only available for our subscribers." msgstr "Jak na razie ten utwór jest dostępny wyłącznie dla naszych Przyjaciół." @@ -817,15 +817,15 @@ msgstr "Czyta" msgid "director:" msgstr "reż." -#: catalogue/templates/catalogue/snippets/jplayer.html:61 +#: catalogue/templates/catalogue/snippets/jplayer.html:64 msgid "previous" msgstr "poprzednia" -#: catalogue/templates/catalogue/snippets/jplayer.html:62 +#: catalogue/templates/catalogue/snippets/jplayer.html:65 msgid "Part" msgstr "Część" -#: catalogue/templates/catalogue/snippets/jplayer.html:63 +#: catalogue/templates/catalogue/snippets/jplayer.html:66 msgid "next" msgstr "następna" diff --git a/src/catalogue/locale/ru/LC_MESSAGES/django.po b/src/catalogue/locale/ru/LC_MESSAGES/django.po index 704d49886..d5c4db59a 100644 --- a/src/catalogue/locale/ru/LC_MESSAGES/django.po +++ b/src/catalogue/locale/ru/LC_MESSAGES/django.po @@ -214,7 +214,7 @@ msgstr "дата создания" msgid "parent number" msgstr "номер родителя" -#: catalogue/models/book.py:69 catalogue/models/bookmedia.py:41 +#: catalogue/models/book.py:69 catalogue/models/bookmedia.py:43 msgid "extra information" msgstr "дополнительная информация" @@ -313,7 +313,7 @@ msgstr "" msgid "file" msgstr "XML файл" -#: catalogue/models/bookmedia.py:50 catalogue/models/bookmedia.py:51 +#: catalogue/models/bookmedia.py:52 catalogue/models/bookmedia.py:53 msgid "book media" msgstr "аудиокнига" @@ -582,7 +582,7 @@ msgstr "код языка" msgid "Read online" msgstr "Читать онлайн" -#: catalogue/templates/catalogue/book_short.html:123 +#: catalogue/templates/catalogue/book_short.html:115 msgid "" "Cena książki w druku cyfrowym jest zależna od liczby stron.
Przed zakupem " "upewnij się, że cena druku na żądanie jest dla Ciebie odpowiednia." @@ -590,24 +590,24 @@ msgid "" "bezpłatnie." msgstr "" -#: catalogue/templates/catalogue/book_short.html:123 +#: catalogue/templates/catalogue/book_short.html:115 msgid "Print on demand –" msgstr "" -#: catalogue/templates/catalogue/book_short.html:128 +#: catalogue/templates/catalogue/book_short.html:120 #: catalogue/templates/catalogue/custom_pdf_form.html:18 catalogue/views.py:404 msgid "Download" msgstr "Загрузить" -#: catalogue/templates/catalogue/book_short.html:142 +#: catalogue/templates/catalogue/book_short.html:134 msgid "more" msgstr "" -#: catalogue/templates/catalogue/book_short.html:153 +#: catalogue/templates/catalogue/book_short.html:145 msgid "less" msgstr "" -#: catalogue/templates/catalogue/book_short.html:161 +#: catalogue/templates/catalogue/book_short.html:153 msgid "For now this work is only available for our subscribers." msgstr "" @@ -896,15 +896,15 @@ msgstr "Артист" msgid "director:" msgstr "режиссер" -#: catalogue/templates/catalogue/snippets/jplayer.html:61 +#: catalogue/templates/catalogue/snippets/jplayer.html:64 msgid "previous" msgstr "" -#: catalogue/templates/catalogue/snippets/jplayer.html:62 +#: catalogue/templates/catalogue/snippets/jplayer.html:65 msgid "Part" msgstr "" -#: catalogue/templates/catalogue/snippets/jplayer.html:63 +#: catalogue/templates/catalogue/snippets/jplayer.html:66 msgid "next" msgstr "" diff --git a/src/catalogue/locale/uk/LC_MESSAGES/django.po b/src/catalogue/locale/uk/LC_MESSAGES/django.po index 629ca15e2..78214aaa3 100644 --- a/src/catalogue/locale/uk/LC_MESSAGES/django.po +++ b/src/catalogue/locale/uk/LC_MESSAGES/django.po @@ -213,7 +213,7 @@ msgstr "дата створення" msgid "parent number" msgstr "номер батька" -#: catalogue/models/book.py:69 catalogue/models/bookmedia.py:41 +#: catalogue/models/book.py:69 catalogue/models/bookmedia.py:43 msgid "extra information" msgstr "додаткова інформація" @@ -311,7 +311,7 @@ msgstr "" msgid "file" msgstr "файл" -#: catalogue/models/bookmedia.py:50 catalogue/models/bookmedia.py:51 +#: catalogue/models/bookmedia.py:52 catalogue/models/bookmedia.py:53 msgid "book media" msgstr "book media" @@ -579,7 +579,7 @@ msgstr "мовний код" msgid "Read online" msgstr "Читати онлайн" -#: catalogue/templates/catalogue/book_short.html:123 +#: catalogue/templates/catalogue/book_short.html:115 msgid "" "Cena książki w druku cyfrowym jest zależna od liczby stron.
Przed zakupem " "upewnij się, że cena druku na żądanie jest dla Ciebie odpowiednia." @@ -587,24 +587,24 @@ msgid "" "bezpłatnie." msgstr "" -#: catalogue/templates/catalogue/book_short.html:123 +#: catalogue/templates/catalogue/book_short.html:115 msgid "Print on demand –" msgstr "" -#: catalogue/templates/catalogue/book_short.html:128 +#: catalogue/templates/catalogue/book_short.html:120 #: catalogue/templates/catalogue/custom_pdf_form.html:18 catalogue/views.py:404 msgid "Download" msgstr "Завантажити" -#: catalogue/templates/catalogue/book_short.html:142 +#: catalogue/templates/catalogue/book_short.html:134 msgid "more" msgstr "" -#: catalogue/templates/catalogue/book_short.html:153 +#: catalogue/templates/catalogue/book_short.html:145 msgid "less" msgstr "" -#: catalogue/templates/catalogue/book_short.html:161 +#: catalogue/templates/catalogue/book_short.html:153 msgid "For now this work is only available for our subscribers." msgstr "" @@ -890,15 +890,15 @@ msgstr "Художник" msgid "director:" msgstr "Режисер" -#: catalogue/templates/catalogue/snippets/jplayer.html:61 +#: catalogue/templates/catalogue/snippets/jplayer.html:64 msgid "previous" msgstr "" -#: catalogue/templates/catalogue/snippets/jplayer.html:62 +#: catalogue/templates/catalogue/snippets/jplayer.html:65 msgid "Part" msgstr "" -#: catalogue/templates/catalogue/snippets/jplayer.html:63 +#: catalogue/templates/catalogue/snippets/jplayer.html:66 msgid "next" msgstr "" diff --git a/src/catalogue/tasks.py b/src/catalogue/tasks.py index 0da624d87..f2ee55f38 100644 --- a/src/catalogue/tasks.py +++ b/src/catalogue/tasks.py @@ -7,7 +7,7 @@ from celery.utils.log import get_task_logger from django.conf import settings from django.utils import timezone -from catalogue.utils import gallery_url +from catalogue.utils import absolute_url, gallery_url from waiter.models import WaitedFile task_logger = get_task_logger(__name__) @@ -53,7 +53,7 @@ def build_custom_pdf(book_id, customizations, file_name, waiter_id=None): pdf = wldoc.as_pdf( customizations=customizations, morefloats=settings.LIBRARIAN_PDF_MOREFLOATS, - base_url=gallery_url(wldoc.book_info.url.slug), + base_url=absolute_url(gallery_url(wldoc.book_info.url.slug)), **kwargs) DefaultStorage().save(file_name, File(open(pdf.get_filename(), 'rb'))) finally: diff --git a/src/catalogue/utils.py b/src/catalogue/utils.py index ca8ec0dc2..916fd7090 100644 --- 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 urllib.parse import urljoin 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 @@ -310,6 +312,16 @@ 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) -- 2.20.1