当前位置: 首页>>代码示例>>Python>>正文


Python Document.set_default_permissions方法代码示例

本文整理汇总了Python中documents.models.Document.set_default_permissions方法的典型用法代码示例。如果您正苦于以下问题:Python Document.set_default_permissions方法的具体用法?Python Document.set_default_permissions怎么用?Python Document.set_default_permissions使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在documents.models.Document的用法示例。


在下文中一共展示了Document.set_default_permissions方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: upload_document

# 需要导入模块: from documents.models import Document [as 别名]
# 或者: from documents.models.Document import set_default_permissions [as 别名]
def upload_document(request):
	if request.method == 'GET':
		return render_to_response('documents/document_upload.html',
								  RequestContext(request),
								  context_instance=RequestContext(request)
		)

	elif request.method == 'POST':
		
		try:
			content_type = ContentType.objects.get(name=request.POST['ctype'])
			object_id = request.POST['objid']
		except:
			content_type = None
			object_id = None
		try:
			int(object_id)
		except: 
			if object_id is not None:
				object_id = Layer.objects.get(uuid=object_id).id

		file = request.FILES['file']
		title = request.POST['title']
		document = Document(content_type=content_type, object_id=object_id, title=title, file=file)
		document.owner = request.user
		document.save()
		document.set_default_permissions()
		permissionsStr = request.POST['permissions']
		permissions = json.loads(permissionsStr)
		set_document_permissions(document, permissions)

		return HttpResponse(json.dumps({'success': True,'redirect_to':'/documents/' + str(document.id)}))
开发者ID:sativa,项目名称:geonode-documents,代码行数:34,代码来源:views.py

示例2: upload_document

# 需要导入模块: from documents.models import Document [as 别名]
# 或者: from documents.models.Document import set_default_permissions [as 别名]
def upload_document(request):
	if request.method == 'GET':
		return render_to_response('documents/document_upload.html',
								  RequestContext(request),
								  context_instance=RequestContext(request)
		)

	elif request.method == 'POST':
		
		try:
			content_type = ContentType.objects.get(name=request.POST['ctype'])
			object_id = request.POST['objid']
		except:
			content_type = None
			object_id = None
		try:
			int(object_id)
		except: 
			if object_id is not None:
				object_id = Layer.objects.get(uuid=object_id).id

		try:
			file = request.FILES['file']
			title = request.POST['title']
		document = Document(content_type=content_type, object_id=object_id, title=title, file=file)
		document.owner = request.user
			document.save()
			document.set_default_permissions()
			permissionsStr = request.POST['permissions']
			permissions = json.loads(permissionsStr)
			set_document_permissions(document, permissions)

			return HttpResponse(json.dumps({
				"success": True,
				"redirect_to": reverse('documents.views.documentdetail', args=[document.id])}))

		except Exception, e:
			logger.exception("Unexpected error during upload.")
			return HttpResponse(json.dumps({
				"success": False,
				"errormsgs": ["Unexpected error during upload"]}))
开发者ID:benmccall,项目名称:geonode-documents,代码行数:43,代码来源:views.py

示例3: upload_document

# 需要导入模块: from documents.models import Document [as 别名]
# 或者: from documents.models.Document import set_default_permissions [as 别名]
def upload_document(request,mapid=None):
	if request.method == 'GET':
		return render_to_response('documents/document_upload.html',
								  RequestContext(request,{'mapid':mapid,}),
								  context_instance=RequestContext(request)
		)

	elif request.method == 'POST':
		try:
			resourceId = str(request.POST['map'])
			file = None
			try:
				file = request.FILES['file']
			except MultiValueDictKeyError as fe:
				file = None
			title = request.POST['title']
			html_lnk_document = request.POST['html_lnk_document']
			htmllink = None
			if(html_lnk_document == "Yes"):
				htmllink = request.POST['documentHtmlLink']
				
			document = Document(title=title, file=file, htmllink=htmllink)
			if request.user.is_authenticated(): document.owner = request.user
			document.save()
			document.set_default_permissions()
			permissionsStr = request.REQUEST['documentPermissions']
			permissions = json.loads(permissionsStr)
			set_document_permissions( document, permissions)
			
			if (resourceId != "" and float(resourceId)):
				docMap = Map.objects.get (id=resourceId)
				if docMap is not None:
					document.maps.add(docMap)
				docLayer = Layer.objects.get(id=resourceId)
				if docLayer is not None:
					document.layers.add(docLayer)	
		except Exception as e:
			logger.error ('Error inside document upload ' + str (e) )
			raise e
		return HttpResponse(json.dumps({'success': True,'redirect_to':'/maps/' + str(mapid)}))
开发者ID:sheetalpgadkari,项目名称:geonode-documents,代码行数:42,代码来源:views.py

示例4: upload_document

# 需要导入模块: from documents.models import Document [as 别名]
# 或者: from documents.models.Document import set_default_permissions [as 别名]
def upload_document(request,mapid=None):
	if request.method == 'GET':
		return render_to_response('documents/document_upload.html',
								  RequestContext(request,{'mapid':mapid,}),
								  context_instance=RequestContext(request)
		)

	elif request.method == 'POST':
		mapid = str(request.POST['map'])
		file = request.FILES['file']
		title = request.POST['title']
		document = Document(title=title, file=file)
		if request.user.is_authenticated(): document.owner = request.user
		document.save()
		document.set_default_permissions()
		permissionsStr = request.POST['permissions']
		permissions = json.loads(permissionsStr)
		set_document_permissions(document, permissions)

		if mapid:
			document.maps.add(Map.objects.get(id=mapid))
		return HttpResponse(json.dumps({'success': True,'redirect_to':'/maps/' + str(mapid)}))
开发者ID:jaywhy13,项目名称:geonode-documents,代码行数:24,代码来源:views.py


注:本文中的documents.models.Document.set_default_permissions方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。