示例#1
0
文件: teams.py 项目: pratz/sentry
def new_team_member(request, team):
    can_add_member = can_add_team_member(request.user, team)
    if not can_add_member:
        return HttpResponseRedirect(reverse("sentry"))

    initial = {"type": MEMBER_USER}

    invite_form = InviteTeamMemberForm(team, request.POST or None, initial=initial, prefix="invite")
    add_form = NewTeamMemberForm(team, request.POST or None, initial=initial, prefix="add")

    if add_form.is_valid():
        pm = add_form.save(commit=False)
        pm.team = team
        pm.save()

        messages.add_message(request, messages.SUCCESS, _("The team member was added."))

        return HttpResponseRedirect(reverse("sentry-edit-team-member", args=[team.slug, pm.id]))

    elif invite_form.is_valid():
        pm = invite_form.save(commit=False)
        pm.team = team
        pm.save()

        pm.send_invite_email()

        return HttpResponseRedirect(reverse("sentry-manage-team", args=[team.slug]) + "?success=1")

    context = csrf(request)
    context.update({"page": "members", "team": team, "add_form": add_form, "invite_form": invite_form})

    return render_to_response("sentry/teams/members/new.html", context, request)
示例#2
0
def new_team_member(request, team):
    from django.conf import settings

    if not can_add_team_member(request.user, team):
        return HttpResponseRedirect(reverse('sentry'))

    initial = {
        'type': MEMBER_USER,
    }

    if settings.SENTRY_ENABLE_INVITES:
        invite_form = InviteTeamMemberForm(team,
                                           request.POST or None,
                                           initial=initial,
                                           prefix='invite')
    else:
        invite_form = None

    add_form = NewTeamMemberForm(team,
                                 request.POST or None,
                                 initial=initial,
                                 prefix='add')

    if add_form.is_valid():
        pm = add_form.save(commit=False)
        pm.team = team
        pm.save()

        messages.add_message(request, messages.SUCCESS,
                             _('The team member was added.'))

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

    elif invite_form and invite_form.is_valid():
        pm = invite_form.save(commit=False)
        pm.team = team
        pm.save()

        pm.send_invite_email()

        messages.add_message(
            request, messages.SUCCESS,
            _('An invitation email was sent to %s.') % (pm.email, ))

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

    context = csrf(request)
    context.update({
        'page': 'members',
        'add_form': add_form,
        'invite_form': invite_form,
        'SUBSECTION': 'members',
    })

    return render_with_team_context(team, 'sentry/teams/members/new.html',
                                    context, request)
示例#3
0
def new_team_member(request, team):
    can_add_member = can_add_team_member(request.user, team)
    if not can_add_member:
        return HttpResponseRedirect(reverse('sentry'))

    initial = {
        'type': MEMBER_USER,
    }

    invite_form = InviteTeamMemberForm(team,
                                       request.POST or None,
                                       initial=initial,
                                       prefix='invite')
    add_form = NewTeamMemberForm(team,
                                 request.POST or None,
                                 initial=initial,
                                 prefix='add')

    if add_form.is_valid():
        pm = add_form.save(commit=False)
        pm.team = team
        pm.save()

        messages.add_message(request, messages.SUCCESS,
                             _('The team member was added.'))

        return HttpResponseRedirect(
            reverse('sentry-edit-team-member', args=[team.slug, pm.id]))

    elif invite_form.is_valid():
        pm = invite_form.save(commit=False)
        pm.team = team
        pm.save()

        pm.send_invite_email()

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

    context = csrf(request)
    context.update({
        'page': 'members',
        'team': team,
        'add_form': add_form,
        'invite_form': invite_form,
    })

    return render_to_response('sentry/teams/members/new.html', context,
                              request)
示例#4
0
def new_team_member(request, team):
    from django.conf import settings

    if not can_add_team_member(request.user, team):
        return HttpResponseRedirect(reverse('sentry'))

    initial = {
        'type': MEMBER_USER,
    }

    if settings.SENTRY_ENABLE_INVITES:
        invite_form = InviteTeamMemberForm(team, request.POST or None, initial=initial, prefix='invite')
    else:
        invite_form = None

    add_form = NewTeamMemberForm(team, request.POST or None, initial=initial, prefix='add')

    if add_form.is_valid():
        pm = add_form.save(commit=False)
        pm.team = team
        pm.save()

        messages.add_message(request, messages.SUCCESS,
            _('The team member was added.'))

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

    elif invite_form and invite_form.is_valid():
        pm = invite_form.save(commit=False)
        pm.team = team
        pm.save()

        pm.send_invite_email()

        messages.add_message(request, messages.SUCCESS,
            _('An invitation email was sent to %s.') % (pm.email,))

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

    context = csrf(request)
    context.update({
        'page': 'members',
        'add_form': add_form,
        'invite_form': invite_form,
        'SUBSECTION': 'members',
    })

    return render_with_team_context(team, 'sentry/teams/members/new.html', context, request)
示例#5
0
文件: teams.py 项目: tsesci/sentry
def new_team_member(request, team):
    can_add_member = can_add_team_member(request.user, team)
    if not can_add_member:
        return HttpResponseRedirect(reverse('sentry'))

    initial = {
        'type': MEMBER_USER,
    }

    invite_form = InviteTeamMemberForm(team, request.POST or None, initial=initial, prefix='invite')
    add_form = NewTeamMemberForm(team, request.POST or None, initial=initial, prefix='add')

    if add_form.is_valid():
        pm = add_form.save(commit=False)
        pm.team = team
        pm.save()

        messages.add_message(request, messages.SUCCESS,
            _('The team member was added.'))

        return HttpResponseRedirect(reverse('sentry-edit-team-member', args=[team.slug, pm.id]))

    elif invite_form.is_valid():
        pm = invite_form.save(commit=False)
        pm.team = team
        pm.save()

        pm.send_invite_email()

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

    context = csrf(request)
    context.update({
        'page': 'members',
        'team': team,
        'add_form': add_form,
        'invite_form': invite_form,
        'SECTION': 'team',
        'SUBSECTION': 'members',
    })

    return render_to_response('sentry/teams/members/new.html', context, request)