本文整理汇总了Python中models.Folder.set_user_from_request方法的典型用法代码示例。如果您正苦于以下问题:Python Folder.set_user_from_request方法的具体用法?Python Folder.set_user_from_request怎么用?Python Folder.set_user_from_request使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Folder
的用法示例。
在下文中一共展示了Folder.set_user_from_request方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: folder_add_typed
# 需要导入模块: from models import Folder [as 别名]
# 或者: from models.Folder import set_user_from_request [as 别名]
def folder_add_typed(request, folder_id=None, response_format='html'):
"Folder add to preselected folder"
folder = None
if folder_id:
folder = get_object_or_404(Folder, pk=folder_id)
if not request.user.profile.has_permission(folder, mode='x'):
folder = None
if request.POST:
if 'cancel' not in request.POST:
folder = Folder()
form = FolderForm(
request.user.profile, folder_id, request.POST, instance=folder)
if form.is_valid():
folder = form.save()
folder.set_user_from_request(request)
return HttpResponseRedirect(reverse('documents_folder_view', args=[folder.id]))
else:
return HttpResponseRedirect(reverse('document_index'))
else:
form = FolderForm(request.user.profile, folder_id)
context = _get_default_context(request)
context.update({'form': form,
'folder': folder})
return render_to_response('documents/folder_add_typed', context,
context_instance=RequestContext(request),
response_format=response_format)
示例2: folder_add
# 需要导入模块: from models import Folder [as 别名]
# 或者: from models.Folder import set_user_from_request [as 别名]
def folder_add(request, response_format='html'):
"New folder form"
if request.POST:
if 'cancel' not in request.POST:
folder = Folder()
form = FolderForm(
request.user.profile, None, request.POST, instance=folder)
if form.is_valid():
folder = form.save()
folder.set_user_from_request(request)
return HttpResponseRedirect(reverse('documents_folder_view', args=[folder.id]))
else:
return HttpResponseRedirect(reverse('document_index'))
else:
form = FolderForm(request.user.profile, None)
context = _get_default_context(request)
context.update({'form': form})
return render_to_response('documents/folder_add', context,
context_instance=RequestContext(request),
response_format=response_format)