예제 #1
0
def new_project_member(request, project):
    form = NewProjectMemberForm(project, request.POST or None, initial={
        'type': MEMBER_USER,
    })
    if form.is_valid():
        pm = form.save(commit=False)
        pm.project = project
        pm.save()

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

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

    return render_to_response('sentry/projects/members/new.html', context, request)
예제 #2
0
def new_project_member(request, project):
    form = NewProjectMemberForm(project,
                                request.POST or None,
                                initial={
                                    'type': MEMBER_USER,
                                })
    if form.is_valid():
        pm = form.save(commit=False)
        pm.project = project
        pm.save()

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

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

    return render_to_response('sentry/projects/members/new.html', context,
                              request)
예제 #3
0
파일: projects.py 프로젝트: dgholz/sentry
def new_project_member(request, project):
    can_add_member = _can_add_project_member(request.user, project)
    if not can_add_member:
        return HttpResponseRedirect(reverse('sentry'))

    initial = {
        'type': MEMBER_USER,
    }

    invite_form = InviteProjectMemberForm(project, request.POST or None, initial=initial, prefix='invite')
    add_form = NewProjectMemberForm(project, request.POST or None, initial=initial, prefix='add')

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

        return HttpResponseRedirect(reverse('sentry-edit-project-member', args=[project.pk, pm.id]) + '?success=1')

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

        pm.send_invite_email()

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

    context = csrf(request)
    context.update({
        'project': project,
        'add_form': add_form,
        'invite_form': invite_form,
    })

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