本文整理汇总了Python中mig_main.utility.Permissions.can_upload_articles方法的典型用法代码示例。如果您正苦于以下问题:Python Permissions.can_upload_articles方法的具体用法?Python Permissions.can_upload_articles怎么用?Python Permissions.can_upload_articles使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mig_main.utility.Permissions
的用法示例。
在下文中一共展示了Permissions.can_upload_articles方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: upload_article
# 需要导入模块: from mig_main.utility import Permissions [as 别名]
# 或者: from mig_main.utility.Permissions import can_upload_articles [as 别名]
def upload_article(request):
""" Upload a printed article """
if not Permissions.can_upload_articles(request.user):
raise PermissionDenied()
form = ArticleForm(request.POST or None, request.FILES or None)
if request.method == 'POST':
if form.is_valid():
form.save()
request.session['success_message'] = ('Article uploaded '
'successfully')
return get_previous_page(request, 'history:cornerstone_view')
else:
request.session['error_message'] = messages.GENERIC_SUBMIT_ERROR
template = loader.get_template('generic_form.html')
context_dict = {
'form': form,
'subnav': 'cornerstone',
'has_files': True,
'submit_name': 'Upload Printed Publication',
'form_title': 'Upload Article',
'help_text': 'Make sure to specify the type of publication.',
'base': 'history/base_history.html',
}
context_dict.update(get_common_context(request))
context_dict.update(get_permissions(request.user))
return HttpResponse(template.render(context_dict, request))
示例2: upload_article
# 需要导入模块: from mig_main.utility import Permissions [as 别名]
# 或者: from mig_main.utility.Permissions import can_upload_articles [as 别名]
def upload_article(request):
if not Permissions.can_upload_articles(request.user):
raise PermissionDenied()
if request.method == 'POST':
form = ArticleForm(request.POST,request.FILES)
if form.is_valid():
form.save()
request.session['success_message']='Article uploaded successfully'
return get_previous_page(request,'history:cornerstone_view')
else:
request.session['error_message']='There were errors in your submission. Please correct the noted errors.'
else:
form = ArticleForm()
template = loader.get_template('generic_form.html')
context_dict = {
'form':form,
'subnav':'cornerstone',
'has_files':True,
'submit_name':'Upload Printed Publication',
'form_title':'Upload Article',
'help_text':'Make sure to specify the type of publication.',
'base':'history/base_history.html',
}
context_dict.update(get_common_context(request))
context_dict.update(get_permissions(request.user))
context = RequestContext(request, context_dict)
return HttpResponse(template.render(context))
示例3: get_permissions
# 需要导入模块: from mig_main.utility import Permissions [as 别名]
# 或者: from mig_main.utility.Permissions import can_upload_articles [as 别名]
def get_permissions(user):
permission_dict={
'can_post':Permissions.can_post_web_article(user),
'can_edit':Permissions.can_approve_web_article(user),
'post_button':Permissions.can_upload_articles(user),
'is_member':hasattr(user,'userprofile') and user.userprofile.is_member(),
'can_process_project_reports': Permissions.can_process_project_reports(user),
}
return permission_dict
示例4: get_permissions
# 需要导入模块: from mig_main.utility import Permissions [as 别名]
# 或者: from mig_main.utility.Permissions import can_upload_articles [as 别名]
def get_permissions(user):
permission_dict={
'can_post':Permissions.can_post_web_article(user),
'post_button':Permissions.can_upload_articles(user),
}
return permission_dict