Ejemplo n.º 1
0
Archivo: views.py Proyecto: invliD/1327
def get_delete_cascade(request, title):
	document = get_object_or_error(Document, request.user, ['change_document'], url_title=title)

	collector = NestedObjects(using=DEFAULT_DB_ALIAS)
	collector.collect([document])
	delete_cascade = collector.nested()

	# remove all subclasses of current document from the list because that does not add much helpful information
	simplified_delete_cascade = []
	for cascade_item in delete_cascade:
		if issubclass(type(document), type(cascade_item)) and not type(document) == type(cascade_item):
			continue
		simplified_delete_cascade.append(cascade_item)

	return HttpResponse(json.dumps(delete_cascade_to_json(simplified_delete_cascade)))
Ejemplo n.º 2
0
def get_delete_cascade(request, title):
    document = get_object_or_404(Document, url_title=title)
    check_permissions(document, request.user, [document.edit_permission_name])

    collector = NestedObjects(using=DEFAULT_DB_ALIAS)
    collector.collect([document])
    delete_cascade = collector.nested()

    # remove all subclasses of current document from the list because that does not add much helpful information
    simplified_delete_cascade = []
    for cascade_item in delete_cascade:
        if issubclass(type(document), type(
                cascade_item)) and not type(document) == type(cascade_item):
            continue
        simplified_delete_cascade.append(cascade_item)

    return HttpResponse(
        json.dumps(delete_cascade_to_json(simplified_delete_cascade)))