Merge branch 'minimal-double-reader' into rwd
authorRadek Czajka <radekczajka@nowoczesnapolska.org.pl>
Tue, 19 Nov 2013 13:12:55 +0000 (14:12 +0100)
committerRadek Czajka <radekczajka@nowoczesnapolska.org.pl>
Tue, 19 Nov 2013 13:12:55 +0000 (14:12 +0100)
1  2 
apps/catalogue/models/book.py
wolnelektury/settings/static.py

@@@ -3,7 -3,7 +3,7 @@@
  # Copyright © Fundacja Nowoczesna Polska. See NOTICE for more information.
  #
  import re
 -from django.conf import settings as settings
 +from django.conf import settings
  from django.core.cache import get_cache
  from django.db import models
  from django.db.models import permalink
@@@ -14,7 -14,7 +14,7 @@@ import jsonfiel
  from catalogue import constants
  from catalogue.fields import EbookField
  from catalogue.models import Tag, Fragment, BookMedia
 -from catalogue.utils import create_zip, split_tags, book_upload_path
 +from catalogue.utils import create_zip, split_tags, book_upload_path, related_tag_name
  from catalogue import app_settings
  from catalogue import tasks
  from newtagging import managers
@@@ -36,7 -36,7 +36,7 @@@ class Book(models.Model)
      created_at    = models.DateTimeField(_('creation date'), auto_now_add=True, db_index=True)
      changed_at    = models.DateTimeField(_('creation date'), auto_now=True, db_index=True)
      parent_number = models.IntegerField(_('parent number'), default=0)
 -    extra_info    = jsonfield.JSONField(_('extra information'), default='{}')
 +    extra_info    = jsonfield.JSONField(_('extra information'), default={})
      gazeta_link   = models.CharField(blank=True, max_length=240)
      wiki_link     = models.CharField(blank=True, max_length=240)
      # files generated during publication
              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:
                      'author', 'kind', 'genre', 'epoch'))
              tags = split_tags(tags)
              for category in tags:
 -                rel['tags'][category] = [
 -                        (t.name, t.slug) for t in tags[category]]
 +                cat = []
 +                for tag in tags[category]:
 +                    tag_info = {'slug': tag.slug}
 +                    for lc, ln in settings.LANGUAGES:
 +                        tag_name = getattr(tag, "name_%s" % lc)
 +                        if tag_name:
 +                            tag_info["name_%s" % lc] = tag_name
 +                    cat.append(tag_info)
 +                rel['tags'][category] = cat
  
              for media_format in BookMedia.formats:
                  rel['media'][media_format] = self.has_media(media_format)
      def pretty_title(self, html_links=False):
          book = self
          rel_info = book.related_info()
 -        names = [(name, Tag.create_url('author', slug))
 -                    for name, slug in rel_info['tags']['author']]
 +        names = [(related_tag_name(tag), Tag.create_url('author', tag['slug']))
 +                    for tag in rel_info['tags'].get('author', ())]
          if 'parents' in rel_info:
              books = [(name, Book.create_url(slug))
                          for name, slug in rel_info['parents']]
@@@ -14,25 -14,36 +14,25 @@@ MEDIA_URL = '/media/
  STATIC_URL = '/static/'
  
  # CSS and JavaScript file groups
 +
 +
  PIPELINE_CSS = {
 -    'all': {
 +    'main': {
          # styles both for mobile and for big screen
          'source_filenames': [
              'css/jquery.countdown.css', 
  
 -            'css/base.css',
 -            'css/cite.css',
 -            'css/header.css',
 -            'css/main_page.css',
 -            'css/dialogs.css',
 -            'css/picture_box.css',
 -            'css/book_box.css',
 -            'css/catalogue.css',
              'sponsors/css/sponsors.css',
 -            'css/auth.css',
 -            'funding/funding.scss',
 -            'polls/polls.scss',
 -            'css/form.scss',
 -
              'css/social/shelf_tags.css',
 +
 +            'uni_form/uni-form.css',
 +            'uni_form/default.uni-form.css',
 +
              'css/ui-lightness/jquery-ui-1.8.16.custom.css',
 +
 +            'scss/main.scss',
          ],
 -        'output_filename': 'css/compressed/all.css',
 -    },
 -    'ie': {
 -        'source_filenames': [
 -            'css/ie.css',
 -        ],
 -        'output_filename': 'css/compressed/ie.css',
 +        'output_filename': 'css/compressed/main.css',
      },
      'book': {
          'source_filenames': [
          ],
          'output_filename': 'css/compressed/book.css',
      },
 +    'book_text': {
 +        'source_filenames': [
 +            'scss/book_text.scss',
 +            'css/new.book.css',
 +        ],
 +        'output_filename': 'css/compressed/book_text.css',
 +    },
      'player': {
          'source_filenames': [
              'jplayer/jplayer.blue.monday.css', 
@@@ -81,8 -85,6 +81,8 @@@ PIPELINE_JS = 
              'player/openplayer.js',
              'js/search.js',
              'funding/funding.js',
 +            
 +            'uni_form/uni-form.js',
              ),
          'output_filename': 'js/base.min.js',
      },
              'js/jquery.eventdelegation.js',
              'js/jquery.scrollto.js',
              'js/jquery.highlightfade.js',
+             'js/book_text/other.js',
              'js/book.js',
              'player/openplayer.js',
          ],
          'output_filename': 'js/book.min.js',
      },
 +    'book_text': {
 +        'source_filenames': [
 +            'js/book_text/*.js',
 +        ],
 +        'output_filename': 'js/book_text.js',
 +    },
      'book_ie': {
          'source_filenames': ('js/ierange-m2.js',),
          'output_filename': 'js/book_ie.min.js',
@@@ -122,12 -119,7 +123,12 @@@ PIPELINE_CSS_COMPRESSOR = Non
  PIPELINE_JS_COMPRESSOR = None
  
  PIPELINE_COMPILERS = (
 -    'pyscss_compiler.PySCSSCompiler',
 +    'pipeline.compilers.sass.SASSCompiler',
 +    # We could probably use PySCSS instead,
 +    # but they have some serious problems, like:
 +    # https://github.com/Kronuz/pyScss/issues/166 (empty list syntax)
 +    # https://github.com/Kronuz/pyScss/issues/258 (bad @media order)
 +    #'pyscss_compiler.PySCSSCompiler',
  )
 -PIPELINE_PYSCSS_BINARY = '/usr/bin/env pyscss'
 -PIPELINE_PYSCSS_ARGUMENTS = ''
 +#PIPELINE_PYSCSS_BINARY = '/usr/bin/env pyscss'
 +#PIPELINE_PYSCSS_ARGUMENTS = ''