Esempio n. 1
0
def manage_project_team(request, project):
    result = plugins.first('has_perm', request.user, 'edit_project', project)
    if result is False and not request.user.has_perm('sentry.can_change_project'):
        return HttpResponseRedirect(reverse('sentry'))

    team = project.team

    if not team:
        member_list = []
        pending_member_list = []
    else:
        member_list = [(tm, tm.user) for tm in team.member_set.select_related('user')]
        pending_member_list = [(pm, pm.email) for pm in team.pending_member_set.all().order_by('email')]

    context = csrf(request)
    context.update({
        'page': 'team',
        'project': project,
        'team': team,
        'member_list': member_list,
        'pending_member_list': pending_member_list,
        'can_add_member': can_add_team_member(request.user, project.team),
        'SECTION': 'settings',
    })

    return render_to_response('sentry/projects/team.html', context, request)
Esempio n. 2
0
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)
Esempio n. 3
0
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)
Esempio n. 4
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)
Esempio n. 5
0
def manage_project_team(request, project):
    result = plugins.first('has_perm', request.user, 'edit_project', project)
    if result is False and not request.user.has_perm(
            'sentry.can_change_project'):
        return HttpResponseRedirect(reverse('sentry'))

    if not project.team:
        member_list = []
    else:
        member_list = [(tm, tm.user)
                       for tm in project.team.member_set.select_related('user')
                       ]

    context = csrf(request)
    context.update({
        'page':
        'team',
        'project':
        project,
        'team':
        project.team,
        'member_list':
        member_list,
        'can_add_member':
        can_add_team_member(request.user, project.team),
    })

    return render_to_response('sentry/projects/team.html', context, request)
Esempio n. 6
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)
Esempio n. 7
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)
Esempio n. 8
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)
Esempio n. 9
0
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)
Esempio n. 10
0
def manage_team_members(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'))

    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')]

    context = csrf(request)
    context.update({
        'can_add_member': can_add_team_member(request.user, team),
        'page': 'members',
        'member_list': member_list,
        'pending_member_list': pending_member_list,
        'SUBSECTION': 'members',
    })

    return render_with_team_context(team, 'sentry/teams/members/index.html', context, request)
Esempio n. 11
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,
        'SECTION': 'team',
        'SUBSECTION': 'members',
    })

    return render_to_response('sentry/teams/members/new.html', context, request)
Esempio n. 12
0
def manage_team_members(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"))

    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")]

    context = csrf(request)
    context.update(
        {
            "can_add_member": can_add_team_member(request.user, team),
            "page": "members",
            "team": team,
            "member_list": member_list,
            "pending_member_list": pending_member_list,
        }
    )

    return render_to_response("sentry/teams/members/index.html", context, request)
Esempio n. 13
0
def manage_project_team(request, project):
    result = plugins.first('has_perm', request.user, 'edit_project', project)
    if result is False and not request.user.has_perm('sentry.can_change_project'):
        return HttpResponseRedirect(reverse('sentry'))

    if not project.team:
        member_list = []
    else:
        member_list = [(tm, tm.user) for tm in project.team.member_set.select_related('user')]

    context = csrf(request)
    context.update({
        'page': 'team',
        'project': project,
        'team': project.team,
        'member_list': member_list,
        'can_add_member': can_add_team_member(request.user, project.team),
    })

    return render_to_response('sentry/projects/team.html', context, request)
Esempio n. 14
0
def manage_project_team(request, project):
    result = plugins.first('has_perm', request.user, 'edit_project', project)
    if result is False and not request.user.has_perm(
            'sentry.can_change_project'):
        return HttpResponseRedirect(reverse('sentry'))

    team = project.team

    if not team:
        member_list = []
        pending_member_list = []
    else:
        member_list = [(tm, tm.user)
                       for tm in team.member_set.select_related('user')]
        pending_member_list = [
            (pm, pm.email)
            for pm in team.pending_member_set.all().order_by('email')
        ]

    context = csrf(request)
    context.update({
        'page':
        'team',
        'project':
        project,
        'team':
        team,
        'member_list':
        member_list,
        'pending_member_list':
        pending_member_list,
        'can_add_member':
        can_add_team_member(request.user, project.team),
        'SECTION':
        'settings',
    })

    return render_to_response('sentry/projects/team.html', context, request)
Esempio n. 15
0
def manage_team_members(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'))

    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')
    ]

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

    return render_to_response('sentry/teams/members/index.html', context,
                              request)
Esempio n. 16
0
def can_add_team_member(user, team):
    from sentry.permissions import can_add_team_member

    return can_add_team_member(user, team)