• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python permissions.can_remove_team函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: manage_team

def manage_team(request, team):
    result = plugins.first('has_perm', request.user, 'edit_team', team)
    if result is False and not request.user.has_perm('sentry.can_change_team'):
        return HttpResponseRedirect(reverse('sentry'))

    form = EditTeamForm(request.POST or None, instance=team)

    if form.is_valid():
        team = form.save()

        return HttpResponseRedirect(request.path + '?success=1')

    member_list = [(pm, pm.user) for pm in team.member_set.select_related('user')]
    pending_member_list = [(pm, pm.email) for pm in team.pending_member_set.all()]

    project_list = list(team.project_set.all())

    context = csrf(request)
    context.update({
        'can_add_member': can_add_team_member(request.user, team),
        'can_remove_team': can_remove_team(request.user, team),
        'page': 'details',
        'form': form,
        'team': team,
        'member_list': member_list,
        'pending_member_list': pending_member_list,
        'project_list': project_list,
    })

    return render_to_response('sentry/teams/manage.html', context, request)
开发者ID:bgyss,项目名称:sentry,代码行数:30,代码来源:teams.py


示例2: handle

    def handle(self, request, organization, team):
        if not can_remove_team(request.user, team):
            return HttpResponseRedirect(reverse('sentry'))

        form = self.get_form(request)

        if form.is_valid():
            team.update(status=TeamStatus.PENDING_DELETION)

            # we delay the task for 5 minutes so we can implement an undo
            kwargs = {'object_id': team.id}
            delete_team.apply_async(kwargs=kwargs, countdown=60 * 5)

            AuditLogEntry.objects.create(
                organization=organization,
                actor=request.user,
                ip_address=request.META['REMOTE_ADDR'],
                target_object=team.id,
                event=AuditLogEntryEvent.TEAM_REMOVE,
                data=team.get_audit_log_data(),
            )

            messages.add_message(
                request, messages.SUCCESS,
                _(u'The team %r was scheduled for deletion.') % (team.name.encode('utf-8'),))

            return HttpResponseRedirect(reverse('sentry'))

        context = {
            'form': form,
        }

        return self.respond('sentry/teams/remove.html', context)
开发者ID:hyongbai,项目名称:sentry,代码行数:33,代码来源:remove_team.py


示例3: manage_team

def manage_team(request, team):
    result = plugins.first("has_perm", request.user, "edit_team", team)
    if result is False and not request.user.has_perm("sentry.can_change_team"):
        return HttpResponseRedirect(reverse("sentry"))

    can_admin_team = request.user == team.owner or request.user.has_perm("sentry.can_add_team")

    if can_admin_team:
        form_cls = EditTeamAdminForm
    else:
        form_cls = EditTeamForm

    form = form_cls(request.POST or None, initial={"owner": team.owner}, instance=team)

    # XXX: form.is_valid() changes the foreignkey
    original_owner = team.owner
    if form.is_valid():

        team = form.save()
        if team.owner != original_owner:
            # Update access for new membership if it's changed
            # (e.g. member used to be USER, but is now OWNER)
            team.member_set.filter(user=team.owner).update(type=MEMBER_OWNER)

        messages.add_message(request, messages.SUCCESS, _("Changes to your team were saved."))

        return HttpResponseRedirect(request.path)

    context = csrf(request)
    context.update(
        {"can_remove_team": can_remove_team(request.user, team), "page": "details", "form": form, "team": team}
    )

    return render_to_response("sentry/teams/manage.html", context, request)
开发者ID:pratz,项目名称:sentry,代码行数:34,代码来源:teams.py


示例4: remove_team

def remove_team(request, team):
    if not can_remove_team(request.user, team):
        return HttpResponseRedirect(reverse('sentry'))

    if request.method == 'POST':
        form = RemoveTeamForm(request.POST)
    else:
        form = RemoveTeamForm()

    if form.is_valid():
        if team.status == TeamStatus.VISIBLE:
            team.update(status=TeamStatus.PENDING_DELETION)
            # we delay the task for 5 minutes so we can implement an undo
            kwargs = {'object_id': team.id}
            delete_team.apply_async(kwargs=kwargs, countdown=60 * 5)

        messages.add_message(
            request, messages.SUCCESS,
            _('Deletion has been queued and will happen automatically.'))

        return HttpResponseRedirect(reverse('sentry'))

    context = csrf(request)
    context.update({
        'page': 'settings',
        'form': form,
        'SUBSECTION': 'settings',
    })

    return render_with_team_context(team, 'sentry/teams/remove.html', context, request)
开发者ID:basco-johnkevin,项目名称:sentry,代码行数:30,代码来源:teams.py


示例5: remove_team

def remove_team(request, team):
    if not can_remove_team(request.user, team):
        return HttpResponseRedirect(reverse("sentry"))

    form = RemoveTeamForm(request.POST or None)

    if form.is_valid():
        team.delete()
        return HttpResponseRedirect(reverse("sentry-team-list"))

    context = csrf(request)
    context.update({"page": "settings", "form": form, "team": team})

    return render_to_response("sentry/teams/remove.html", context, request)
开发者ID:pratz,项目名称:sentry,代码行数:14,代码来源:teams.py


示例6: manage_team

def manage_team(request, team):
    result = plugins.first('has_perm', request.user, 'edit_team', team)
    if result is False and not request.user.is_superuser:
        return HttpResponseRedirect(reverse('sentry'))

    can_admin_team = request.user == team.owner or request.user.is_superuser

    if can_admin_team:
        form_cls = EditTeamAdminForm
    else:
        form_cls = EditTeamForm

    form = form_cls(request.POST or None, initial={
        'owner': team.owner,
    }, instance=team)

    # XXX: form.is_valid() changes the foreignkey
    original_owner = team.owner
    if form.is_valid():

        team = form.save()
        if team.owner != original_owner:
            # Update access for new membership if it's changed
            # (e.g. member used to be USER, but is now OWNER)
            TeamMember.objects.create_or_update(
                user=team.owner,
                team=team,
                defaults={
                    'type': MEMBER_OWNER,
                }
            )
            team.project_set.update(
                owner=team.owner,
            )

        messages.add_message(request, messages.SUCCESS,
            _('Changes to your team were saved.'))

        return HttpResponseRedirect(reverse('sentry-manage-team', args=[team.slug]))

    context = csrf(request)
    context.update({
        'can_remove_team': can_remove_team(request.user, team),
        'page': 'details',
        'form': form,
        'SUBSECTION': 'settings',
    })

    return render_with_team_context(team, 'sentry/teams/manage.html', context, request)
开发者ID:DNIWE-Systems,项目名称:sentry,代码行数:49,代码来源:teams.py


示例7: remove_team

def remove_team(request, team):
    if not can_remove_team(request.user, team):
        return HttpResponseRedirect(reverse('sentry'))

    form = RemoveTeamForm(request.POST or None)

    if form.is_valid():
        team.delete()
        return HttpResponseRedirect(reverse('sentry-team-list'))

    context = csrf(request)
    context.update({
        'form': form,
        'team': team,
    })

    return render_to_response('sentry/teams/remove.html', context, request)
开发者ID:bgyss,项目名称:sentry,代码行数:17,代码来源:teams.py


示例8: manage_team

def manage_team(request, team):
    result = plugins.first('has_perm', request.user, 'edit_team', team)
    if result is False and not request.user.has_perm('sentry.can_change_team'):
        return HttpResponseRedirect(reverse('sentry'))

    if request.user.has_perm('sentry.can_add_team'):
        form_cls = EditTeamAdminForm
    else:
        form_cls = EditTeamForm

    form = form_cls(request.POST or None, initial={
        'owner': team.owner,
    }, instance=team)

    # XXX: form.is_valid() changes the foreignkey
    original_owner = team.owner
    if form.is_valid():

        team = form.save()
        if team.owner != original_owner:
            # Update access for new membership if it's changed
            # (e.g. member used to be USER, but is now OWNER)
            team.member_set.filter(user=team.owner).update(type=MEMBER_OWNER)

        return HttpResponseRedirect(request.path + '?success=1')

    member_list = [(pm, pm.user) for pm in team.member_set.select_related('user').order_by('user__username')]
    pending_member_list = [(pm, pm.email) for pm in team.pending_member_set.all().order_by('email')]

    project_list = list(team.project_set.all())

    context = csrf(request)
    context.update({
        'can_add_project': can_create_projects(request.user, team),
        'can_add_member': can_add_team_member(request.user, team),
        'can_remove_team': can_remove_team(request.user, team),
        'page': 'details',
        'form': form,
        'team': team,
        'member_list': member_list,
        'pending_member_list': pending_member_list,
        'project_list': project_list,
    })

    return render_to_response('sentry/teams/manage.html', context, request)
开发者ID:allanlei,项目名称:sentry,代码行数:45,代码来源:teams.py


示例9: remove_team

def remove_team(request, team):
    if not can_remove_team(request.user, team):
        return HttpResponseRedirect(reverse('sentry'))

    if request.method == 'POST':
        form = RemoveTeamForm(request.POST)
    else:
        form = RemoveTeamForm()

    if form.is_valid():
        team.delete()
        return HttpResponseRedirect(reverse('sentry-team-list'))

    context = csrf(request)
    context.update({
        'page': 'settings',
        'form': form,
        'SUBSECTION': 'settings',
    })

    return render_with_team_context(team, 'sentry/teams/remove.html', context, request)
开发者ID:DouweM,项目名称:sentry,代码行数:21,代码来源:teams.py


示例10: remove_team

def remove_team(request, team):
    if not can_remove_team(request.user, team):
        return HttpResponseRedirect(reverse('sentry'))

    if request.method == 'POST':
        form = RemoveTeamForm(request.POST)
    else:
        form = RemoveTeamForm()

    if form.is_valid():
        team.delete()
        messages.add_message(
            request, messages.SUCCESS,
            _(u'The team %r was permanently deleted.') % (team.name.encode('utf-8'),))
        return HttpResponseRedirect(reverse('sentry'))

    context = csrf(request)
    context.update({
        'page': 'settings',
        'form': form,
        'SUBSECTION': 'settings',
    })

    return render_with_team_context(team, 'sentry/teams/remove.html', context, request)
开发者ID:SmashingDevelopment,项目名称:sentry,代码行数:24,代码来源:teams.py


示例11: get_default_context

 def get_default_context(self, request, **kwargs):
     context = super(TeamSettingsView, self).get_default_context(request, **kwargs)
     context.update({
         'can_remove_team': can_remove_team(request.user, kwargs['team']),
     })
     return context
开发者ID:PostPCEra,项目名称:sentry,代码行数:6,代码来源:team_settings.py


示例12: import

"""
sentry.templatetags.sentry_permissions
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

:copyright: (c) 2010-2014 by the Sentry Team, see AUTHORS for more details.
:license: BSD, see LICENSE for more details.
"""
from __future__ import absolute_import

from django import template

from sentry.permissions import (
    can_create_organizations, can_create_teams, can_create_projects,
    can_remove_team, can_remove_project, can_manage_project, can_manage_team,
    can_manage_org
)

register = template.Library()

# TODO: Django doesn't seem to introspect function args correctly for filters
# so we can't just register.filter(can_add_team_member)
register.filter('can_create_organizations')(lambda a: can_create_organizations(a))
register.filter('can_create_teams')(lambda a, b: can_create_teams(a, b))
register.filter('can_create_projects')(lambda a, b: can_create_projects(a, b))
register.filter('can_manage_team')(lambda a, b: can_manage_team(a, b))
register.filter('can_manage_project')(lambda a, b: can_manage_project(a, b))
register.filter('can_manage_org')(lambda a, b: can_manage_org(a, b))
register.filter('can_remove_team')(lambda a, b: can_remove_team(a, b))
register.filter('can_remove_project')(lambda a, b: can_remove_project(a, b))
开发者ID:Simek,项目名称:sentry,代码行数:29,代码来源:sentry_permissions.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python plugins.register函数代码示例发布时间:2022-05-27
下一篇:
Python permissions.can_remove_project函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap