本文整理汇总了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)}))
示例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"]}))
示例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)}))
示例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)}))