本文整理汇总了Python中tendenci.core.perms.utils.has_view_perm函数的典型用法代码示例。如果您正苦于以下问题:Python has_view_perm函数的具体用法?Python has_view_perm怎么用?Python has_view_perm使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了has_view_perm函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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)
开发者ID:simonqiang,项目名称:tendenci,代码行数:7,代码来源:views.py
示例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'))
开发者ID:jkimma,项目名称:tendenci,代码行数:28,代码来源:views.py
示例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))
开发者ID:keith9raceland,项目名称:tendenci,代码行数:26,代码来源:views.py
示例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)
开发者ID:bleven,项目名称:tendenci,代码行数:7,代码来源:views.py
示例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'))
开发者ID:legutierr,项目名称:tendenci,代码行数:28,代码来源:views.py
示例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
开发者ID:jkimma,项目名称:tendenci,代码行数:31,代码来源:views.py
示例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))
开发者ID:droidterry,项目名称:tendenci,代码行数:25,代码来源:views.py
示例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
开发者ID:warhotdog,项目名称:tendenci,代码行数:8,代码来源:views.py
示例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
开发者ID:bleven,项目名称:tendenci,代码行数:8,代码来源:views.py
示例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))
开发者ID:bpotterschipul,项目名称:tendenci,代码行数:8,代码来源:views.py
示例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))
开发者ID:kaisatec,项目名称:tendenci,代码行数:9,代码来源:views.py
示例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
开发者ID:warhotdog,项目名称:tendenci,代码行数:9,代码来源:views.py
示例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
开发者ID:Spacepoints,项目名称:tendenci,代码行数:10,代码来源:views.py
示例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
开发者ID:warhotdog,项目名称:tendenci,代码行数:10,代码来源:views.py
示例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
开发者ID:Spacepoints,项目名称:tendenci,代码行数:10,代码来源:views.py
示例16: details
def details(request, slug=None, template_name="directories/view.html"):
if not slug: return HttpResponseRedirect(reverse('directories'))
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
开发者ID:guyt101z,项目名称:tendenci,代码行数:11,代码来源:views.py
示例17: detail
def detail(request, slug, template_name="help_files/details.html"):
"""Help file details"""
help_file = get_object_or_404(HelpFile, slug=slug)
if has_view_perm(request.user, 'help_files.view_helpfile', help_file):
HelpFile.objects.filter(pk=help_file.pk).update(view_totals=help_file.view_totals+1)
EventLog.objects.log(instance=help_file)
return render_to_response(template_name, {'help_file': help_file},
context_instance=RequestContext(request))
else:
raise Http403
开发者ID:DeepInTheCode,项目名称:tendenci,代码行数:11,代码来源:views.py
示例18: details
def details(request, id=None, template_name="stories/view.html"):
if not id: return HttpResponseRedirect(reverse('story.search'))
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))
开发者ID:kaisatec,项目名称:tendenci,代码行数:11,代码来源:views.py
示例19: index
def index(request, slug=None, id=None, hash=None,
template_name="pages/view.html"):
"""
Return page object, either as an archive, active, or version.
"""
if not slug and not id and not hash:
return HttpResponseRedirect(reverse('page.search'))
if hash:
version = get_object_or_404(Version, hash=hash)
current_page = get_object_or_404(Page, pk=version.object_id)
page = version.get_version_object()
messages.add_message(request, messages.WARNING,
'You are viewing a previous version of this article. View the ' + \
'<a href="%s">Current Version</a>.' % current_page.get_absolute_url())
elif id:
page = get_object_or_404(Page, pk=id)
if page.status_detail != 'active':
if not request.user.is_authenticated():
pages = Page.objects.filter(
slug=page.slug, status_detail='active'
).order_by('-pk')
if not pages:
pages = Page.objects.filter(slug=slug).order_by('-pk')
if not pages:
raise Http404
return HttpResponseRedirect(reverse('page', args=[page.slug]))
else:
try:
page = get_object_or_404(Page, slug=slug)
except Page.MultipleObjectsReturned:
pages = Page.objects.filter(
slug=slug, status_detail='active'
).order_by('-pk')
if not pages:
pages = Page.objects.filter(slug=slug).order_by('-pk')
if not pages:
raise Http404
page = pages[0]
if not has_view_perm(request.user, 'pages.view_page', page):
raise Http403
if not page.template or not check_template(page.template):
page.template = "pages/base.html"
EventLog.objects.log(instance=page)
return render_to_response(template_name, {'page': page},
context_instance=RequestContext(request))
开发者ID:legutierr,项目名称:tendenci,代码行数:53,代码来源:views.py
示例20: detail
def detail(request, id, template_name="navs/detail.html"):
nav = get_object_or_404(Nav, id=id)
if not has_view_perm(request.user, 'navs.view_nav', nav):
raise Http403
EventLog.objects.log(instance=nav)
return render_to_response(
template_name,
{'current_nav':nav},
context_instance=RequestContext(request),
)
开发者ID:Spacepoints,项目名称:tendenci,代码行数:13,代码来源:views.py
注:本文中的tendenci.core.perms.utils.has_view_perm函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论