- if not gallery and not objects and len(tags) == 1:
- tag = tags[0]
- if (tag.category in ('theme', 'thing') and PictureArea.tagged.with_any([tag]).exists() or
- Picture.tagged.with_any([tag]).exists()):
- return redirect('tagged_object_list_gallery', raw_tags, permanent=False)
-
- return render_to_response('catalogue/tagged_object_list.html',
- {
- 'object_list': objects,
- 'categories': categories,
- 'only_shelf': only_shelf,
- 'only_my_shelf': only_my_shelf,
- 'formats_form': forms.DownloadFormatsForm(),
- 'tags': tags,
- 'tag_ids': tags_pks,
- 'theme_is_set': theme_is_set,
- 'best': best,
- 'gallery': gallery,
- },
- context_instance=RequestContext(request))
-
-
-def book_fragments(request, slug, theme_slug):
- book = get_object_or_404(models.Book, slug=slug)
- theme = get_object_or_404(models.Tag, slug=theme_slug, category='theme')
- fragments = models.Fragment.tagged.with_all([theme]).filter(
- Q(book=book) | Q(book__ancestor=book))
-
- return render_to_response('catalogue/book_fragments.html', locals(),
- context_instance=RequestContext(request))
-
-
-def book_detail(request, slug):
- try:
- book = models.Book.objects.get(slug=slug)
- except models.Book.DoesNotExist:
- return pdcounter_views.book_stub_detail(request, slug)
-
- tags = book.tags.exclude(category__in=('set', 'theme'))
- book_children = book.children.all().order_by('parent_number', 'sort_key')
- return render_to_response('catalogue/book_detail.html', locals(),
- context_instance=RequestContext(request))
-
-
-def get_audiobooks(book):
- ogg_files = {}
- for m in book.media.filter(type='ogg').order_by().iterator():
- ogg_files[m.name] = m
-
- audiobooks = []
- have_oggs = True
- projects = set()
- for mp3 in book.media.filter(type='mp3').iterator():
- # ogg files are always from the same project
- meta = mp3.extra_info
- project = meta.get('project')
- if not project:
- # temporary fallback
- project = u'CzytamySłuchając'
-
- projects.add((project, meta.get('funded_by', '')))
-
- media = {'mp3': mp3}
-
- ogg = ogg_files.get(mp3.name)
- if ogg:
- media['ogg'] = ogg
- else:
- have_oggs = False
- audiobooks.append(media)
-
- projects = sorted(projects)
- return audiobooks, projects, have_oggs
-
-
-def player(request, slug):
- book = get_object_or_404(models.Book, slug=slug)
- if not book.has_media('mp3'):
- raise Http404
-
- audiobooks, projects, have_oggs = get_audiobooks(book)
-
- extra_info = book.extra_info
-
- return render_to_response('catalogue/player.html', locals(),
- context_instance=RequestContext(request))
-
-
-def book_text(request, slug):
- book = get_object_or_404(models.Book, slug=slug)