本文整理汇总了Python中mig_main.utility.Permissions.can_update_mindset_materials方法的典型用法代码示例。如果您正苦于以下问题:Python Permissions.can_update_mindset_materials方法的具体用法?Python Permissions.can_update_mindset_materials怎么用?Python Permissions.can_update_mindset_materials使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mig_main.utility.Permissions
的用法示例。
在下文中一共展示了Permissions.can_update_mindset_materials方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: update_mindset_photos
# 需要导入模块: from mig_main.utility import Permissions [as 别名]
# 或者: from mig_main.utility.Permissions import can_update_mindset_materials [as 别名]
def update_mindset_photos(request):
if not Permissions.can_update_mindset_materials(request.user):
request.session['error_message']='You are not authorized to update MindSET Materials'
return redirect('outreach:mindset')
MindSETPhotoForm = modelformset_factory(OutreachPhoto,can_delete=True)
if request.method=='POST':
formset = MindSETPhotoForm(request.POST,request.FILES,prefix='mindset')
if formset.is_valid():
instances = formset.save()
request.session['success_message']='Photos successfully updated.'
return redirect('outreach:mindset')
else:
request.session['error_message']='Your submission contained errors, please correct and resubmit.'
else:
formset=MindSETPhotoForm(prefix='mindset')
context_dict = {
'formset':formset,
'prefix':'mindset',
'subnav':'mindset',
'has_files':True,
'submit_name':'Update MindSET Photos',
'back_button':{'link':reverse('outreach:mindset'),'text':'To MindSET Page'},
'form_title':'Edit MindSET Photos',
'help_text':'You can update the photos for the MindSET section of the website here.',
'can_add_row':True,
'base':'outreach/base_outreach.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_formset.html')
return HttpResponse(template.render(context))
示例2: get_permissions
# 需要导入模块: from mig_main.utility import Permissions [as 别名]
# 或者: from mig_main.utility.Permissions import can_update_mindset_materials [as 别名]
def get_permissions(user):
permission_dict = {
'can_edit_mindset': Permissions.can_update_mindset_materials(user),
'can_edit_outreach': user.is_superuser,
'can_edit_profiles': Permissions.can_manage_officers(user),
}
return permission_dict
示例3: update_mindset_modules
# 需要导入模块: from mig_main.utility import Permissions [as 别名]
# 或者: from mig_main.utility.Permissions import can_update_mindset_materials [as 别名]
def update_mindset_modules(request):
if not Permissions.can_update_mindset_materials(request.user):
request.session['error_message'] = ('You are not authorized to '
'update MindSET Materials')
return redirect('outreach:mindset')
MindSETModuleForm = modelformset_factory(MindSETModule, can_delete=True)
formset = MindSETModuleForm(
request.POST or None,
request.FILES or None,
prefix='mindset'
)
if request.method == 'POST':
if formset.is_valid():
instances = formset.save()
request.session['success_message'] = 'Modules updated.'
return redirect('outreach:mindset')
else:
request.session['error_message'] = messages.GENERIC_SUBMIT_ERROR
context_dict = {
'formset': formset,
'prefix': 'mindset',
'subnav': 'mindset',
'has_files': True,
'submit_name': 'Update Modules',
'back_button': {
'link': reverse('outreach:mindset'),
'text': 'To MindSET Page'
},
'form_title': 'Edit MindSET Module Resources',
'help_text': ('Keep track of the resources associated with MindSET '
'modules here.'),
'can_add_row': True,
'base': 'outreach/base_outreach.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_formset.html')
return HttpResponse(template.render(context))
示例4: get_permissions
# 需要导入模块: from mig_main.utility import Permissions [as 别名]
# 或者: from mig_main.utility.Permissions import can_update_mindset_materials [as 别名]
def get_permissions(user):
permission_dict={
'can_edit_mindset':Permissions.can_update_mindset_materials(user),
'can_edit_outreach':user.is_superuser,
}
return permission_dict
示例5: get_permissions
# 需要导入模块: from mig_main.utility import Permissions [as 别名]
# 或者: from mig_main.utility.Permissions import can_update_mindset_materials [as 别名]
def get_permissions(user):
permission_dict={'can_edit_mindset':Permissions.can_update_mindset_materials(user),}
return permission_dict