本文整理汇总了Python中tendenci.core.perms.utils.has_view_perm函数的典型用法代码示例。如果您正苦于以下问题:Python has_view_perm函数的具体用法?Python has_view_perm怎么用?Python has_view_perm使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了has_view_perm函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: display_header_image
def display_header_image(request, id):
page = get_object_or_404(Page, pk=id)
if not has_view_perm(request.user, "[pages.view_page", page):
raise Http403
return file_display(request, page.header_image.file.name)
示例2: group_membership_self_add
def group_membership_self_add(request, slug, user_id):
group = get_object_or_404(Group, slug=slug)
user = get_object_or_404(User, pk=user_id)
if not has_view_perm(request.user,'user_groups.view_group', group) and not group.allow_self_add:
raise Http403
group_membership = GroupMembership.objects.filter(member=user, group=group)
if not group_membership:
group_membership = GroupMembership()
group_membership.group = group
group_membership.member = user
group_membership.creator_id = user.id
group_membership.creator_username = user.username
group_membership.owner_id = user.id
group_membership.owner_username = user.username
group_membership.save()
EventLog.objects.log(instance=group_membership)
messages.add_message(request, messages.SUCCESS, 'Successfully added yourself to group %s' % group)
else:
messages.add_message(request, messages.INFO, 'You are already in the group %s' % group)
return HttpResponseRedirect(reverse('group.search'))
示例3: photoset_details
def photoset_details(request, id, template_name="photos/photo-set/details.html"):
""" View photos in photo set """
photo_set = get_object_or_404(PhotoSet, id=id)
if not has_view_perm(request.user, 'photos.view_photoset', photo_set):
raise Http403
order = get_setting('module', 'photos', 'photoordering')
#if order == 'descending':
# photos = photo_set.get_images(user=request.user).order_by('-pk')
#else:
# photos = photo_set.get_images(user=request.user).order_by('pk')
photos = photo_set.get_images(user=request.user).order_by("position")
EventLog.objects.log(**{
'event_id': 991500,
'event_data': '%s (%d) viewed by %s' % (photo_set._meta.object_name, photo_set.pk, request.user),
'description': '%s viewed' % photo_set._meta.object_name,
'user': request.user,
'request': request,
'instance': photo_set,
})
return render_to_response(template_name, {
"photos": photos,
"photo_set": photo_set,
}, context_instance=RequestContext(request))
示例4: logo_display
def logo_display(request, id):
directory = get_object_or_404(Directory, pk=id)
if not has_view_perm(request.user, "directories.view_directory", directory):
raise Http403
return file_display(request, directory.logo.name)
示例5: group_membership_self_remove
def group_membership_self_remove(request, slug, user_id):
group = get_object_or_404(Group, slug=slug)
if not has_view_perm(request.user,'user_groups.view_group', group) and not group.allow_self_remove:
raise Http403
user = get_object_or_404(User, pk=user_id)
group_membership = GroupMembership.objects.filter(member=user, group=group)
if group_membership:
group_membership = group_membership[0]
if group_membership.member == user:
log_defaults = {
'event_id' : 223000,
'event_data': '%s (%d) deleted by %s' % (group_membership._meta.object_name, group_membership.pk, request.user),
'description': '%s deleted' % group_membership._meta.object_name,
'user': request.user,
'request': request,
'instance': group_membership,
}
EventLog.objects.log(**log_defaults)
group_membership.delete()
messages.add_message(request, messages.SUCCESS, 'Successfully removed yourself from group %s' % group)
else:
messages.add_message(request, messages.INFO, 'You are not in the group %s' % group)
return HttpResponseRedirect(reverse('group.search'))
示例6: detail
def detail(request, slug=None, hash=None, template_name="articles/view.html"):
if not slug and not hash:
return HttpResponseRedirect(reverse('articles'))
if hash:
version = get_object_or_404(Version, hash=hash)
current_article = get_object_or_404(Article, pk=version.object_id)
article = version.get_version_object()
messages.add_message(request, messages.WARNING, 'You are viewing a previous version of this article. View the <a href="%s%s">Current Version</a>.' % (get_setting('site', 'global', 'siteurl'), current_article.get_absolute_url()))
else:
article = get_object_or_404(Article, slug=slug)
# non-admin can not view the non-active content
# status=0 has been taken care of in the has_perm function
if (article.status_detail).lower() != 'active' and (not request.user.profile.is_superuser):
raise Http403
if article.release_dt >= datetime.now():
if not any([
has_perm(request.user, 'articles.view_article'),
request.user == article.owner,
request.user == article.creator
]):
raise Http403
if has_view_perm(request.user, 'articles.view_article', article):
EventLog.objects.log(instance=article)
return render_to_response(template_name, {'article': article},
context_instance=RequestContext(request))
else:
raise Http403
示例7: group_detail
def group_detail(request, group_slug, template_name="user_groups/detail.html"):
group = get_object_or_404(Group, slug=group_slug)
if not has_view_perm(request.user,'user_groups.view_group',group):
raise Http403
if group in request.user.profile.get_groups():
is_group_member = True
gm = GroupMembership.objects.get(group=group, member=request.user)
else:
is_group_member = False
gm = None
EventLog.objects.log(instance=group)
groupmemberships = GroupMembership.objects.filter(
group=group,
status=True,
status_detail='active').order_by('member__last_name')
count_members = len(groupmemberships)
return render_to_response(
template_name,
locals(),
context_instance=RequestContext(request))
示例8: print_view
def print_view(request, id, template_name="contacts/print-view.html"):
contact = get_object_or_404(Contact, pk=id)
if has_view_perm(request.user,'contacts.view_contact',contact):
return render_to_response(template_name, {'contact': contact},
context_instance=RequestContext(request))
else:
raise Http403
示例9: print_view
def print_view(request, slug, template_name="directories/print-view.html"):
directory = get_object_or_404(Directory, slug=slug)
if has_view_perm(request.user, "directories.view_directory", directory):
EventLog.objects.log(instance=directory)
return render_to_response(template_name, {"directory": directory}, context_instance=RequestContext(request))
else:
raise Http403
示例10: print_view
def print_view(request, id, template_name="files/print-view.html"):
file = get_object_or_404(File, pk=id)
# check permission
if not has_view_perm(request.user, "files.view_file", file):
raise Http403
return render_to_response(template_name, {"file": file}, context_instance=RequestContext(request))
示例11: print_details
def print_details(request, id, template_name="stories/print_details.html"):
story = get_object_or_404(Story, pk=id)
if not has_view_perm(request.user,'stories.view_story', story):
raise Http403
EventLog.objects.log(instance=story)
return render_to_response(template_name, {'story': story},
context_instance=RequestContext(request))
示例12: details
def details(request, id=None, template_name="contacts/view.html"):
if not id: return HttpResponseRedirect(reverse('contacts'))
contact = get_object_or_404(Contact, pk=id)
if has_view_perm(request.user,'contacts.view_contact',contact):
return render_to_response(template_name, {'contact': contact},
context_instance=RequestContext(request))
else:
raise Http403
示例13: print_view
def print_view(request, id, template_name="locations/print-view.html"):
location = get_object_or_404(Location, pk=id)
if has_view_perm(request.user,'locations.view_location',location):
EventLog.objects.log(instance=location)
return render_to_response(template_name, {'location': location},
context_instance=RequestContext(request))
else:
raise Http403
示例14: print_view
def print_view(request, slug, template_name="resumes/print-view.html"):
resume = get_object_or_404(Resume, slug=slug)
EventLog.objects.log(instance=resume)
if has_view_perm(request.user,'resumes.view_resume',resume):
return render_to_response(template_name, {'resume': resume},
context_instance=RequestContext(request))
else:
raise Http403
示例15: detail
def detail(request, id=None, template_name="locations/view.html"):
if not id: return HttpResponseRedirect(reverse('locations'))
location = get_object_or_404(Location, pk=id)
if has_view_perm(request.user,'locations.view_location',location):
EventLog.objects.log(instance=location)
return render_to_response(template_name, {'location': location},
context_instance=RequestContext(request))
else:
raise Http403