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


Python Permissions.can_upload_articles方法代码示例

本文整理汇总了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))
开发者ID:tbpmig,项目名称:mig-website,代码行数:28,代码来源:views.py

示例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))
开发者ID:pritpaul,项目名称:mig-website,代码行数:29,代码来源:views.py

示例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
开发者ID:pritpaul,项目名称:mig-website,代码行数:11,代码来源:views.py

示例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
开发者ID:kylelady,项目名称:mig-website,代码行数:8,代码来源:views.py


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