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


Python Permissions.can_add_corporate_contact方法代码示例

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


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

示例1: get_permissions

# 需要导入模块: from mig_main.utility import Permissions [as 别名]
# 或者: from mig_main.utility.Permissions import can_add_corporate_contact [as 别名]
def get_permissions(user):
    permission_dict = {
        'can_edit_corporate': Permissions.can_edit_corporate_page(user),
        'can_add_contact': Permissions.can_add_corporate_contact(user),
        'can_edit_contacts': Permissions.can_edit_corporate_page(user),
        'can_add_company': Permissions.can_add_company(user),
    }
    return permission_dict
开发者ID:dadrian,项目名称:mig-website,代码行数:10,代码来源:views.py

示例2: add_company_contact

# 需要导入模块: from mig_main.utility import Permissions [as 别名]
# 或者: from mig_main.utility.Permissions import can_add_corporate_contact [as 别名]
def add_company_contact(request):
    if not Permissions.can_add_corporate_contact(request.user):
        request.session['error_message'] = 'You are not authorized to add company contacts'
        return redirect('corporate:index')
    prefix = 'corporate_page'
    can_edit = Permissions.can_edit_corporate_page(request.user)
    form = AddContactForm(request.POST or None,prefix=prefix,can_edit=can_edit)
    if request.method == 'POST':
        if form.is_valid():
            if form.is_overdetermined():
                request.session['warning_message'] = 'Name, email, phone, bio, and chapter are ignored when profile provided.'  
            instance = form.save()
            request.session['success_message'] = 'Corporate contact successfully added.'
            return redirect('corporate:index')
        else:
            request.session['error_message'] = FORM_ERROR
    help_text = 'Add a contact to the company contacts database.'
    if not can_edit:
        help_text = help_text + (' Note: you are adding a suggested contact; '
                                 'they will not be emailed unless approved by '
                                 'the Corporate Relations Officer.')
    context_dict = {
        'form': form,
        'subnav': 'index',
        'prefix': prefix,
        'has_files': False,
        'submit_name': 'Add company contact',
        'back_button': {'link': reverse('corporate:index'),
                        'text': 'To Corporate Page'},
        'form_title': 'Add company contact',
        'help_text': help_text,
        'base': 'corporate/base_corporate.html',
        }
    context_dict.update(get_common_context(request))
    context_dict.update(get_permissions(request.user))
    context = RequestContext(request, context_dict)
    template = loader.get_template('generic_form.html')
    return HttpResponse(template.render(context))
开发者ID:dadrian,项目名称:mig-website,代码行数:40,代码来源:views.py


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