本文整理汇总了Python中mig_main.utility.Permissions.can_add_company方法的典型用法代码示例。如果您正苦于以下问题:Python Permissions.can_add_company方法的具体用法?Python Permissions.can_add_company怎么用?Python Permissions.can_add_company使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mig_main.utility.Permissions
的用法示例。
在下文中一共展示了Permissions.can_add_company方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: add_jobfield
# 需要导入模块: from mig_main.utility import Permissions [as 别名]
# 或者: from mig_main.utility.Permissions import can_add_company [as 别名]
def add_jobfield(request):
if not Permissions.can_add_company(request.user):
request.session['error_message'] = 'You are not authorized to add industries'
return redirect('corporate:index')
prefix = 'corporate_page'
AddIndustryForm = modelform_factory(JobField)
form = AddIndustryForm(request.POST or None,prefix=prefix)
if request.method == 'POST':
if form.is_valid():
instance = form.save()
request.session['success_message'] = 'Industry successfully added.'
return redirect('corporate:index')
else:
request.session['error_message'] = FORM_ERROR
context_dict = {
'form': form,
'subnav': 'index',
'prefix': prefix,
'has_files': False,
'submit_name': 'Add industry',
'back_button': {'link': reverse('corporate:index'),
'text': 'To Corporate Page'},
'form_title': 'Add industry',
'help_text': ('Add industry information. Select all relevant majors.'),
'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))
示例2: add_company
# 需要导入模块: from mig_main.utility import Permissions [as 别名]
# 或者: from mig_main.utility.Permissions import can_add_company [as 别名]
def add_company(request):
if not Permissions.can_add_company(request.user):
request.session['error_message'] = 'You are not authorized to add companies'
return redirect('corporate:index')
prefix = 'corporate_page'
AddCompanyForm = modelform_factory(Company, exclude=[])
form = AddCompanyForm(request.POST or None,prefix=prefix)
if request.method == 'POST':
if form.is_valid():
instance = form.save()
request.session['success_message'] = 'Company successfully added.'
return redirect('corporate:index')
else:
request.session['error_message'] = FORM_ERROR
context_dict = {
'form': form,
'subnav': 'index',
'prefix': prefix,
'has_files': False,
'submit_name': 'Add company',
'back_button': {'link': reverse('corporate:index'),
'text': 'To Corporate Page'},
'form_title': 'Add company',
'help_text': ('Add company information. If the appropriate industry '
'is not present, you need to add that first'),
'base': 'corporate/base_corporate.html',
}
context_dict.update(get_common_context(request))
context_dict.update(get_permissions(request.user))
template = loader.get_template('generic_form.html')
return HttpResponse(template.render(context_dict, request))
示例3: get_permissions
# 需要导入模块: from mig_main.utility import Permissions [as 别名]
# 或者: from mig_main.utility.Permissions import can_add_company [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