Пример #1
0
def document_detail(request, docid):
    """
    The view that show details of each document
    """
    document = get_object_or_404(Document, pk=docid)
    if not request.user.has_perm("documents.view_document", obj=document):
        return HttpResponse(
            loader.render_to_string(
                "401.html", RequestContext(request, {"error_message": _("You are not allowed to view this document.")})
            ),
            status=401,
        )
    try:
        related = document.content_type.get_object_for_this_type(id=document.object_id)
    except:
        related = ""

    document.popular_count += 1
    document.save()

    return render_to_response(
        "documents/document_detail.html",
        RequestContext(
            request,
            {
                "permissions_json": json.dumps(_perms_info(document, DOCUMENT_LEV_NAMES)),
                "document": document,
                "imgtypes": IMGTYPES,
                "related": related,
            },
        ),
    )
Пример #2
0
def documentdetail(request, docid):
	"""
	The view that show details of each document
	"""
	document = get_object_or_404(Document, pk=docid)
	if not request.user.has_perm('documents.view_document', obj=document):
		return HttpResponse(loader.render_to_string('401.html',
			RequestContext(request, {'error_message':
				_("You are not allowed to view this document.")})), status=401)

	return render_to_response("documents/docinfo.html", RequestContext(request, {
		'permissions_json': json.dumps(_perms_info(document, DOCUMENT_LEV_NAMES)),
		'document': document,
		'imgtypes': imgtypes
	}))