def view(request, title): document = get_object_or_404(Document, url_title=title) content_type = ContentType.objects.get_for_model(document) check_permissions(document, request.user, [document.view_permission_name]) try: function = get_model_function(content_type, 'view') return function(request, title) except (ImportError, AttributeError): pass text, toc = convert_markdown(document.text) return render( request, 'documents_base.html', { 'document': document, 'text': text, 'toc': toc, 'attachments': document.attachments.filter( no_direct_download=False).order_by('index'), 'active_page': 'view', 'view_page': True, 'permission_overview': document_permission_overview(request.user, document), })
def view(request, title): document = get_object_or_404(Document, url_title=title) content_type = ContentType.objects.get_for_model(document) check_permissions(document, request.user, [document.view_permission_name]) try: function = get_model_function(content_type, 'view') return function(request, title) except (ImportError, AttributeError): pass if document.text == "" and (document.text_en != "" or document.text_de != ""): messages.warning( request, _('The requested document is not available in the selected language. It will be shown in the available language instead.' )) text, toc = convert_markdown( next((text for text in (document.text_de, document.text_en) if text != ""), "")) else: text, toc = convert_markdown(document.text) return render( request, 'documents_base.html', { 'document': document, 'text': text, 'toc': toc, 'attachments': document.attachments.filter( no_direct_download=False).order_by('index'), 'active_page': 'view', 'view_page': True, 'permission_overview': document_permission_overview(request.user, document), })
def view(request, title): document = get_object_or_404(Document, url_title=title) content_type = ContentType.objects.get_for_model(document) check_permissions(document, request.user, [document.view_permission_name]) try: function = get_model_function(content_type, 'view') return function(request, title) except (ImportError, AttributeError): pass text, toc = convert_markdown(document.text) return render(request, 'documents_base.html', { 'document': document, 'text': text, 'toc': toc, 'attachments': document.attachments.filter(no_direct_download=False).order_by('index'), 'active_page': 'view', 'view_page': True, 'permission_overview': document_permission_overview(request.user, document), })
def view(request, title): document = Document.objects.get(url_title=title) content_type = ContentType.objects.get_for_model(document) check_permissions(document, request.user, [document.view_permission_name]) try: function = get_model_function(content_type, 'view') return function(request, title) except (ImportError, AttributeError): pass md = markdown.Markdown(safe_mode='escape', extensions=[TocExtension(baselevel=2), InternalLinksMarkdownExtension()]) text = md.convert(document.text) return render(request, 'documents_base.html', { 'document': document, 'text': text, 'toc': md.toc, 'attachments': document.attachments.filter(no_direct_download=False).order_by('index'), 'active_page': 'view', 'permission_warning': permission_warning(request.user, content_type, document), })