当前位置: 首页>>代码示例>>Python>>正文


Python utils.has_view_perm函数代码示例

本文整理汇总了Python中tendenci.apps.perms.utils.has_view_perm函数的典型用法代码示例。如果您正苦于以下问题:Python has_view_perm函数的具体用法?Python has_view_perm怎么用?Python has_view_perm使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了has_view_perm函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: group_detail

def group_detail(request, group_slug, template_name="user_groups/detail.html"):
    group = get_object_or_404(Group, slug=group_slug)
    membership_view_perms = get_setting('module', 'memberships', 'memberprotection')

    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)

    if request.user.profile.is_superuser or membership_view_perms <> 'private': 
        groupmemberships = GroupMembership.objects.filter(
            group=group,
            status=True,
            status_detail='active').order_by('member__last_name')
    else:
        groupmemberships = GroupMembership.objects.none()

    count_members = len(groupmemberships)
    return render_to_response(
        template_name,
        locals(),
        context_instance=RequestContext(request))
开发者ID:jiwonlee777,项目名称:tendenci,代码行数:29,代码来源:views.py

示例2: 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:goetzk,项目名称:tendenci,代码行数:26,代码来源:views.py

示例3: 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:a2call,项目名称:tendenci,代码行数:7,代码来源:views.py

示例4: 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()
        msg_string = '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())
        messages.add_message(request, messages.WARNING, _(msg_string))
    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 not article.release_dt_local and article.release_dt:
        article.assign_release_dt_local()

    if not article.release_dt_local or article.release_dt_local >= 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_resp(request=request, template_name=template_name,
            context={'article': article})
    else:
        raise Http403
开发者ID:tendenci,项目名称:tendenci,代码行数:35,代码来源:views.py

示例5: 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)

        if group_membership.is_newsletter_subscribed:
            group_membership.subscribe_to_newsletter()

        messages.add_message(request, messages.SUCCESS, _('Successfully added yourself to group %(grp)s' % {'grp':group}))
    else:
        messages.add_message(request, messages.INFO, _('You are already in the group %(grp)s' % {'grp': group}))

    return HttpResponseRedirect(reverse('group.search'))
开发者ID:jiwonlee777,项目名称:tendenci,代码行数:31,代码来源:views.py

示例6: 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:goetzk,项目名称:tendenci,代码行数:8,代码来源:views.py

示例7: 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_resp(request=request, template_name=template_name,
            context={'contact': contact})
    else:
        raise Http403
开发者ID:tendenci,项目名称:tendenci,代码行数:8,代码来源:views.py

示例8: 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:RMUCapstone-MIS590,项目名称:tendenci,代码行数:9,代码来源: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:RMUCapstone-MIS590,项目名称:tendenci,代码行数:9,代码来源:views.py

示例10: 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_resp(request=request, template_name=template_name,
            context={'contact': contact})
    else:
        raise Http403
开发者ID:tendenci,项目名称:tendenci,代码行数:9,代码来源: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:BIGGANI,项目名称:tendenci,代码行数:9,代码来源:views.py

示例12: 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:BIGGANI,项目名称:tendenci,代码行数:10,代码来源:views.py

示例13: 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:RMUCapstone-MIS590,项目名称:tendenci,代码行数:11,代码来源:views.py

示例14: 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:BIGGANI,项目名称:tendenci,代码行数:11,代码来源:views.py

示例15: print_view

def print_view(request, slug, template_name="jobs/print-view.html"):
    job = get_object_or_404(Job, slug=slug)

    can_view = has_view_perm(request.user, 'jobs.view_job', job)

    if can_view:
        EventLog.objects.log(instance=job)

        return render_to_response(template_name, {'job': job},
            context_instance=RequestContext(request))
    else:
        raise Http403
开发者ID:ediaz1,项目名称:tendenci,代码行数:12,代码来源:views.py


注:本文中的tendenci.apps.perms.utils.has_view_perm函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。