from django.template.loader import render_to_string
from django.shortcuts import get_object_or_404, render, redirect
from django.http import HttpResponse, HttpResponseRedirect, Http404, HttpResponsePermanentRedirect
from django.template.loader import render_to_string
from django.shortcuts import get_object_or_404, render, redirect
from django.http import HttpResponse, HttpResponseRedirect, Http404, HttpResponsePermanentRedirect
from annoy.models import DynamicTextInsert
from pdcounter import views as pdcounter_views
from picture.models import Picture, PictureArea
from annoy.models import DynamicTextInsert
from pdcounter import views as pdcounter_views
from picture.models import Picture, PictureArea
from catalogue.models import Book, Collection, Tag, Fragment
from catalogue.utils import split_tags
from catalogue.models.tag import prefetch_relations
from catalogue.models import Book, Collection, Tag, Fragment
from catalogue.utils import split_tags
from catalogue.models.tag import prefetch_relations
return render(request, 'catalogue/catalogue.html', {
'books': Book.objects.filter(findable=True, parent=None),
'pictures': Picture.objects.all(),
return render(request, 'catalogue/catalogue.html', {
'books': Book.objects.filter(findable=True, parent=None),
'pictures': Picture.objects.all(),
def collection(request, slug):
coll = get_object_or_404(Collection, slug=slug)
def collection(request, slug):
coll = get_object_or_404(Collection, slug=slug)
- return render(request, 'catalogue/collection.html', {'collection': coll})
+ return render(request, 'catalogue/collection.html', {
+ 'collection': coll,
+ 'active_menu_item': 'collections',
+ })
except Book.DoesNotExist:
return pdcounter_views.book_stub_detail(request, slug)
except Book.DoesNotExist:
return pdcounter_views.book_stub_detail(request, slug)
{
'book': book,
'book_children': book.children.all().order_by('parent_number', 'sort_key'),
'active_menu_item': 'books',
{
'book': book,
'book_children': book.children.all().order_by('parent_number', 'sort_key'),
'active_menu_item': 'books',
+ 'club_form': ScheduleForm() if book.preview else None,
+ 'club': Club.objects.first() if book.preview else None,
+
+ 'EXPERIMENTS_SWITCHABLE_layout': True,
def book_text(request, slug):
book = get_object_or_404(Book, slug=slug)
def book_text(request, slug):
book = get_object_or_404(Book, slug=slug)
_("An error occurred: %(exception)s\n\n%(tb)s") % {
'exception': exception, 'tb': tb
},
_("An error occurred: %(exception)s\n\n%(tb)s") % {
'exception': exception, 'tb': tb
},
)
return HttpResponse(_("Book imported successfully"))
return HttpResponse(_("Error importing file: %r") % book_import_form.errors)
)
return HttpResponse(_("Book imported successfully"))
return HttpResponse(_("Error importing file: %r") % book_import_form.errors)
return HttpResponseRedirect(book.get_absolute_url())
return super(CustomPDFFormView, self).validate_object(obj, request)
return HttpResponseRedirect(book.get_absolute_url())
return super(CustomPDFFormView, self).validate_object(obj, request)