def document(request, project_slug, document_id): o = {} qs = Document.objects.select_related('project') o['document'] = get_object_or_404(Document, id=document_id, project__slug=project_slug) o['breadcrumb'] = ( (o['document'].project.name, o['document'].project.get_absolute_url()), ('Documents', reverse('all_documents_view', kwargs={'project_slug': o['document'].project.slug})), (o['document'].as_text(), None) ) o['topics'] = ( [ ta.topic for ta in o['document'].related_topics.all() ] + [ c.content_object for c in o['document'].citations.filter( content_type=ContentType.objects.get_for_model(Topic)) ]) o['scans'] = o['document'].scans.all() o['domain'] = Site.objects.get_current().domain notes = [ns.note for ns in CitationNS.objects\ .select_related('note')\ .filter(document=o['document'])] note_topics = [ [ ta.topic for ta in n.related_topics.all() ] for n in notes ] o['notes'] = zip(notes, note_topics) if o['document'].zotero_data: o['zotero_data'] = as_readable(o['document'].zotero_data) if o['document'].zotero_link: o['zotero_url'] = o['document'].zotero_link.zotero_url o['zotero_date_information'] = o['document'].zotero_link.date_information return render_to_response( 'document.html', o, context_instance=RequestContext(request))
def document(request, document_id): o = {} o['document'] = get_object_or_404(Document, id=document_id) o['topics'] = ( [ ta.topic for ta in o['document'].topics.all() ] + [ c.content_object for c in o['document'].citations.filter( content_type=ContentType.objects.get_for_model(Topic)) ]) o['scans'] = o['document'].scans.all() o['domain'] = Site.objects.get_current().domain notes = [ c.content_object for c in o['document'].citations.filter( content_type=ContentType.objects.get_for_model(Note)) ] o['notes'] = zip(notes, [ [ ta.topic for ta in n.topics.all() ] for n in notes ], [ _sort_citations(n) for n in notes ]) if o['document'].zotero_link(): o['zotero_data'] = as_readable(o['document'].zotero_link().zotero_data) o['zotero_url'] = o['document'].zotero_link().zotero_url o['zotero_date_information'] = o['document'].zotero_link().date_information # view transcript on page open if only it exists if not o['scans'] and o['document'].transcript: redirect_url = o['document'].get_absolute_url() + "?redirect=1#transcript" if request.REQUEST.get('redirect', ''): pass else: return HttpResponseRedirect(redirect_url) else: pass return render_to_response( 'document.html', o, context_instance=RequestContext(request))
def document(request, document_id): o = {} o['document'] = get_object_or_404(Document, id=document_id) o['topics'] = ( [ ta.topic for ta in o['document'].topics.all() ] + [ c.content_object for c in o['document'].citations.filter( content_type=ContentType.objects.get_for_model(Topic)) ]) o['scans'] = o['document'].scans.all() o['domain'] = Site.objects.get_current().domain notes = Note.objects.filter(sections__document=o['document']) note_topics = [ [ ta.topic for ta in n.topics.all() ] for n in notes ] o['notes'] = zip(notes, note_topics) if o['document'].zotero_link(): o['zotero_data'] = as_readable(o['document'].zotero_link().zotero_data) o['zotero_url'] = o['document'].zotero_link().zotero_url o['zotero_date_information'] = o['document'].zotero_link().date_information return render_to_response( 'document.html', o, context_instance=RequestContext(request))