本文整理汇总了Python中mig_main.utility.Permissions.can_manage_website方法的典型用法代码示例。如果您正苦于以下问题:Python Permissions.can_manage_website方法的具体用法?Python Permissions.can_manage_website怎么用?Python Permissions.can_manage_website使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mig_main.utility.Permissions
的用法示例。
在下文中一共展示了Permissions.can_manage_website方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: update_about_photos
# 需要导入模块: from mig_main.utility import Permissions [as 别名]
# 或者: from mig_main.utility.Permissions import can_manage_website [as 别名]
def update_about_photos(request):
if not Permissions.can_manage_website(request.user):
request.session['error_message']='You are not authorized to update about page photos'
return redirect('about:index')
AboutPhotoForm = modelformset_factory(AboutSlideShowPhoto, can_delete=True)
if request.method=='POST':
formset = AboutPhotoForm(request.POST,request.FILES,prefix='about_photo')
if formset.is_valid():
instances = formset.save()
request.session['success_message']='About page photos successfully updated.'
return redirect('about:index')
else:
request.session['error_message']='Your submision contained errors, please correct and resubmit.'
else:
formset=AboutPhotoForm(prefix='about_photo')
context_dict = {
'formset':formset,
'prefix':'about_photo',
'subnav':'about',
'has_files':True,
'submit_name':'Update About Page Photos',
'back_button':{'link':reverse('about:index'),'text':'To About Page'},
'form_title':'Edit About Page Photos',
'help_text':'These are the photos shown in the about page photo slideshow. You can omit a photo from being displayed by unchecking the \"Active\" option.',
'can_add_row':True,
'base':'about/base_about.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_manage_website [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),
}
return permission_dict
示例3: update_about_photos
# 需要导入模块: from mig_main.utility import Permissions [as 别名]
# 或者: from mig_main.utility.Permissions import can_manage_website [as 别名]
def update_about_photos(request):
"""
Standard form view based on the generic_formset. Used to update the photos
in the about landing page.
"""
denied_message = 'You are not authorized to update about page photos'
if not Permissions.can_manage_website(request.user):
request.session['error_message'] = denied_message
return redirect('about:index')
# messages and static text:
success_msg = 'About page photos successfully updated.'
help_text = ('These are the photos shown in the about page photo '
'slideshow. You can omit a photo from being displayed by '
'unchecking the \"Active\" option.')
prefix = 'about_photo'
AboutPhotoForm = modelformset_factory(AboutSlideShowPhoto, can_delete=True,
exclude=[])
if request.method == 'POST':
formset = AboutPhotoForm(request.POST, request.FILES, prefix=prefix)
if formset.is_valid():
instances = formset.save()
request.session['success_message'] = success_msg
return redirect('about:index')
else:
request.session['error_message'] = FORM_ERROR
else:
formset = AboutPhotoForm(prefix=prefix)
context_dict = {
'formset': formset,
'prefix': prefix,
'subnav': 'about',
'has_files': True,
'submit_name': 'Update About Page Photos',
'back_button': {'link': reverse('about:index'),
'text': 'To About Page'},
'form_title': 'Edit About Page Photos',
'help_text': help_text,
'can_add_row': True,
'base': 'about/base_about.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_manage_website [as 别名]
def get_permissions(user):
permission_dict={
'can_edit_about_photos':Permissions.can_manage_website(user),
}
return permission_dict