def reader(request, publication_id): publication_model = get_model_for_publication() manager = get_manager_for_publication(publication_model) pub = get_object_or_404(manager, pk=int(publication_id)) context = { 'publication': pub, 'latest_publication' : get_manager_for_publication(publication_model).latest(), 'first_publication' : get_manager_for_publication(publication_model).reverse().latest() } return render_to_response('digitalpaper/reader.html', context, context_instance=RequestContext(request))
def reader_publication(request, *args, **kwargs): publication_model = get_model_for_publication() manager = get_manager_for_publication(publication_model) pub = get_object_or_404(manager, pk=int(kwargs['id'])) data = { 'books': [] } for book in pub.book_set.all(): bookdata = { "pagination": book.pagination, "pages": [], } for page in book.paperpage_set.all(): pagedata = { 'maps': {}, # FIXME 'page_number': page.page_number, 'id': page.pk, 'paper_channel': page.paper_channel, } bookdata['pages'].append(pagedata) data['books'].append(bookdata) result = json.dumps(data, cls=DateTimeAwareJSONEncoder, indent=1) return HttpResponse(result, mimetype='text/javascript')
def reader_latest(request): publication_model = get_model_for_publication() pub = get_manager_for_publication(publication_model).latest() return redirect('digitalpaper_reader', publication_id=pub.pk)