本文整理汇总了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)
示例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)
示例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)
示例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)
示例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)
示例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)
示例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)
示例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)
示例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)
示例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)
示例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
示例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))