#
import re
import itertools
-from datetime import datetime
from django.conf import settings
from django.template import RequestContext
from django.shortcuts import render_to_response, get_object_or_404
from django.http import HttpResponse, HttpResponseRedirect, Http404, HttpResponsePermanentRedirect
from django.core.urlresolvers import reverse
-from django.db.models import Count, Sum, Q
+from django.db.models import Q
from django.contrib.auth.decorators import login_required, user_passes_test
from django.utils.datastructures import SortedDict
-from django.views.decorators.http import require_POST
-from django.contrib import auth
-from django.contrib.auth.forms import UserCreationForm, AuthenticationForm
from django.utils.http import urlquote_plus
-from django.views.decorators import cache
from django.utils import translation
-from django.utils.translation import ugettext as _
-from django.views.generic.list_detail import object_list
+from django.utils.translation import ugettext as _, ugettext_lazy
+from django.views.decorators.cache import never_cache
-from ajaxable.utils import LazyEncoder, JSONResponse, AjaxableFormView
+from ajaxable.utils import JSONResponse, AjaxableFormView
from catalogue import models
from catalogue import forms
from catalogue.utils import (split_tags, AttachmentHttpResponse,
async_build_pdf, MultiQuerySet)
-from catalogue.tasks import touch_tag
from pdcounter import models as pdcounter_models
from pdcounter import views as pdcounter_views
from suggest.forms import PublishingSuggestForm
context_instance=RequestContext(request))
+@never_cache
def tagged_object_list(request, tags=''):
- # import pdb; pdb.set_trace()
try:
tags = models.Tag.get_tag_list(tags)
except models.Tag.DoesNotExist:
'only_my_shelf': only_my_shelf,
'formats_form': forms.DownloadFormatsForm(),
'tags': tags,
+ 'theme_is_set': theme_is_set,
},
context_instance=RequestContext(request))
context_instance=RequestContext(request))
+@never_cache
def book_detail(request, slug):
try:
book = models.Book.objects.get(slug=slug)
except models.Book.DoesNotExist:
- return pdcounter_views.book_stub_detail(request, kwargs['slug'])
+ return pdcounter_views.book_stub_detail(request, slug)
- book_tag = book.book_tag()
- tags = list(book.tags.filter(~Q(category='set')))
- categories = split_tags(tags)
book_children = book.children.all().order_by('parent_number', 'sort_key')
-
- _book = book
- parents = []
- while _book.parent:
- parents.append(_book.parent)
- _book = _book.parent
- parents = reversed(parents)
-
- theme_counter = book.theme_counter
- book_themes = models.Tag.objects.filter(pk__in=theme_counter.keys())
- for tag in book_themes:
- tag.count = theme_counter[tag.pk]
-
- extra_info = book.get_extra_info_value()
- hide_about = extra_info.get('about', '').startswith('http://wiki.wolnepodreczniki.pl')
-
- custom_pdf_form = forms.CustomPDFForm()
return render_to_response('catalogue/book_detail.html', locals(),
context_instance=RequestContext(request))
else:
have_oggs = False
audiobooks.append(media)
- print audiobooks
projects = sorted(projects)
+ extra_info = book.get_extra_info_value()
+
return render_to_response('catalogue/player.html', locals(),
context_instance=RequestContext(request))
class CustomPDFFormView(AjaxableFormView):
form_class = forms.CustomPDFForm
- title = _('Download custom PDF')
- submit = _('Download')
+ title = ugettext_lazy('Download custom PDF')
+ submit = ugettext_lazy('Download')
def __call__(self, request):
from copy import copy
if request.method == 'POST':
request.GET = copy(request.GET)
- request.GET['next'] = "%s?%s" % (reverse('catalogue.views.download_custom_pdf', args=[request.GET['slug']]),
+ request.GET['next'] = "%s?%s" % (reverse('catalogue.views.download_custom_pdf', args=[request.GET.get('slug')]),
request.POST.urlencode())
return super(CustomPDFFormView, self).__call__(request)
-
+
+ def get_object(self, request):
+ return get_object_or_404(models.Book, slug=request.GET.get('slug'))
+
+ def context_description(self, request, obj):
+ return obj.pretty_title()
def success(self, *args):
pass