From ca9f237a37a38af28136307a5e372c40265907b6 Mon Sep 17 00:00:00 2001 From: Radek Czajka Date: Tue, 19 Nov 2013 09:20:50 +0100 Subject: [PATCH] Minimal double reader. --- apps/catalogue/models/book.py | 4 +++ .../templates/catalogue/book_text.html | 26 ++++++++++++++++++- .../static/css/master.book.css | 10 ++++--- wolnelektury/settings/static.py | 1 + 4 files changed, 37 insertions(+), 4 deletions(-) diff --git a/apps/catalogue/models/book.py b/apps/catalogue/models/book.py index d69cf2aca..9025e3e5b 100644 --- a/apps/catalogue/models/book.py +++ b/apps/catalogue/models/book.py @@ -391,6 +391,10 @@ class Book(models.Model): for child in self.children.all(): child.parent_cover_changed() + def other_versions(self): + """Find other versions (i.e. in other languages) of the book.""" + return type(self).objects.filter(common_slug=self.common_slug).exclude(pk=self.pk) + def related_info(self): """Keeps info about related objects (tags, media) in cache field.""" if self._related_info is not None: diff --git a/apps/catalogue/templates/catalogue/book_text.html b/apps/catalogue/templates/catalogue/book_text.html index f6f2f993e..c4031a6c4 100644 --- a/apps/catalogue/templates/catalogue/book_text.html +++ b/apps/catalogue/templates/catalogue/book_text.html @@ -29,6 +29,9 @@
  • {% trans "Listen" %}
  • {% endif %} + {% if book.other_versions.exists %} +
  • Inne wersje
  • + {% endif %}
    @@ -58,10 +61,31 @@ {% endif %}
    + {% if book.other_versions.exists %} +
    + +
    + {% endif %} - {{ book.html_file.read|safe }} + +
    + {{ book.html_file.read|safe }} + +
    {{ piwik_tag|safe }} diff --git a/apps/wolnelektury_core/static/css/master.book.css b/apps/wolnelektury_core/static/css/master.book.css index be5492726..edea7930c 100644 --- a/apps/wolnelektury_core/static/css/master.book.css +++ b/apps/wolnelektury_core/static/css/master.book.css @@ -11,10 +11,14 @@ a { } #book-text { - margin: 3em; + margin: 0 3em; max-width: 36em; } +#other-text #book-text { + width: 36em; +} + /* ================================== */ /* = Header with logo and menu = */ /* ================================== */ @@ -89,7 +93,7 @@ img { } -#toc, #themes, #nota_red, #info { +#toc, #themes, #nota_red, #info, #other-versions { position: fixed; left: 0em; top: 1.5em; @@ -163,7 +167,7 @@ img { /* =================================================== */ h1 { font-size: 3em; - margin: 1.5em 0; + margin: 0 0 1.5em 0; text-align: center; line-height: 1.5em; font-weight: bold; diff --git a/wolnelektury/settings/static.py b/wolnelektury/settings/static.py index a3ff42430..c38db38d1 100644 --- a/wolnelektury/settings/static.py +++ b/wolnelektury/settings/static.py @@ -101,6 +101,7 @@ PIPELINE_JS = { 'js/jquery.eventdelegation.js', 'js/jquery.scrollto.js', 'js/jquery.highlightfade.js', + 'js/book_text/other.js', 'js/book.js', 'player/openplayer.js', ], -- 2.20.1