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


Python Permissions.can_manage_bylaws方法代码示例

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


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

示例1: update_bylaws

# 需要导入模块: from mig_main.utility import Permissions [as 别名]
# 或者: from mig_main.utility.Permissions import can_manage_bylaws [as 别名]
def update_bylaws(request):
    denied_message = 'You are not authorized to update bylaws.'
    if not Permissions.can_manage_bylaws(request.user):
        request.session['error_message'] = denied_message
        return redirect('about:bylaws')
    form = GoverningDocumentForm(request.POST or None, request.FILES or None)
    if request.method == 'POST':
        if form.is_valid():
            form.save()
            request.session['success_message'] = ('Document uploaded '
                                                  'successfully')
            return get_previous_page(request, 'about:bylaws')
        else:
            request.session['error_message'] = messages.GENERIC_SUBMIT_ERROR
    template = loader.get_template('generic_form.html')
    context_dict = {
        'form': form,
        'subnav': 'bylaws',
        'has_files': True,
        'submit_name': 'Update Governing Document',
        'form_title': 'Upload New Version of Governing Document',
        'help_text': 'This will replace the existing document of this type.',
        'base': 'about/base_about.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,代码行数:29,代码来源:views.py

示例2: get_permissions

# 需要导入模块: from mig_main.utility import Permissions [as 别名]
# 或者: from mig_main.utility.Permissions import can_manage_bylaws [as 别名]
def get_permissions(user):
    """
    Standardized way of querying user permissions across the website.
    Permissions for the entire (or most of it) module are loaded into
    a dictionary that gets merged with the template context to provide
    the template with a list of permissions so as to generate the page
    correctly.
    """
    permission_dict = {
            'can_edit_about_photos': Permissions.can_manage_website(user),
            'can_edit_bylaws': Permissions.can_manage_bylaws(user),
    }
    return permission_dict
开发者ID:tbpmig,项目名称:mig-website,代码行数:15,代码来源:views.py

示例3: update_governing_doc_types

# 需要导入模块: from mig_main.utility import Permissions [as 别名]
# 或者: from mig_main.utility.Permissions import can_manage_bylaws [as 别名]
def update_governing_doc_types(request):
    """
    Standard form view based on the generic_formset. Used to update the text
    in the joining page.
    """
    denied_message = 'You are not authorized to update bylaws.'
    if not Permissions.can_manage_bylaws(request.user):
        request.session['error_message'] = denied_message
        return redirect('about:bylaws')
    prefix = 'bylaws'
    # messages and static text
    success_message = 'Governing doc types updated successfully updated.'

    formset = GoverningDocumentTypeFormset(request.POST or None, prefix=prefix)
    if request.method == 'POST':
        if formset.is_valid():
            instances = formset.save()
            request.session['success_message'] = success_message
            return redirect('about:bylaws')
        else:
            request.session['error_message'] = FORM_ERROR
    context_dict = {
        'formset': formset,
        'prefix': prefix,
        'subnav': 'bylaws',
        'has_files': False,
        'submit_name': 'Update Governing Document Types',
        'back_button': {'link': reverse('about:bylaws'),
                        'text': 'To Bylaws Page'},
        'form_title': 'Update or Add Governing Document Types',
        'help_text': 'Used to add or rename governing document types.',
        'can_add_row': True,
        'base': 'about/base_about.html',
    }
    context_dict.update(get_common_context(request))
    context_dict.update(get_permissions(request.user))
    template = loader.get_template('generic_formset.html')
    return HttpResponse(template.render(context_dict,request))
开发者ID:tbpmig,项目名称:mig-website,代码行数:40,代码来源:views.py


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