import random
from django.conf import settings
-from django.http.response import HttpResponseForbidden
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.views.decorators.cache import never_cache
from ajaxable.utils import AjaxableFormView
-from club.models import Membership
+from club.forms import ScheduleForm
+from club.models import Club, Membership
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 wolnelektury.utils import is_crawler
staff_required = user_passes_test(lambda user: user.is_staff)
# TODO: Pictures on shelves not supported yet.
books = Book.tagged.with_all(shelf_tags).order_by()
fragments = fragments.filter(Q(book__in=books) | Q(book__ancestor__in=books))
- else:
+ elif list_type == 'books':
fragments = fragments.filter(book__findable=True)
if not fragments and len(tags) == 1 and list_type == 'books':
except ResponseInstead as e:
return e.response
- if is_crawler(request) and len(tags) > 1:
- return HttpResponseForbidden('address removed from crawling. check robots.txt')
-
if list_type == 'gallery' and any(tag.category == 'set' for tag in tags):
raise Http404
'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,
})
_("An error occurred: %(exception)s\n\n%(tb)s") % {
'exception': exception, 'tb': tb
},
- mimetype='text/plain'
+ content_type='text/plain'
)
return HttpResponse(_("Book imported successfully"))
return HttpResponse(_("Error importing file: %r") % book_import_form.errors)