def create_new_team_project(request, team):
    from sentry.web.forms.projects import NewProjectAdminForm, NewProjectForm

    if not can_create_projects(request.user, team):
        return missing_perm(request, Permissions.ADD_PROJECT, team=team)

    if request.user.has_perm('sentry.can_add_project'):
        form_cls = NewProjectAdminForm
        initial = {
            'owner': request.user.username,
        }
    else:
        form_cls = NewProjectForm
        initial = {}

    form = form_cls(request.POST or None, initial=initial)
    if form.is_valid():
        project = form.save(commit=False)
        project.team = team
        if not project.owner:
            project.owner = request.user
        project.save()

        if project.platform not in (None, 'other'):
            return HttpResponseRedirect(reverse('sentry-docs-client', args=[project.team.slug, project.slug, project.platform]))
        return HttpResponseRedirect(reverse('sentry-get-started', args=[project.team.slug, project.slug]))

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

    return render_with_team_context(team, 'sentry/teams/projects/new.html', context, request)
Esempio n. 2
0
def create_new_team(request):
    if not can_create_teams(request.user):
        return missing_perm(request, Permissions.ADD_TEAM)

    if request.user.has_perm('sentry.can_add_team'):
        form_cls = NewTeamAdminForm
        initial = {
            'owner': request.user.username,
        }
    else:
        form_cls = NewTeamForm
        initial = {}

    form = form_cls(request.POST or None, initial=initial)
    if form.is_valid():
        team = form.save(commit=False)
        if not team.owner_id:
            team.owner = request.user
        team.save()
        return HttpResponseRedirect(reverse('sentry-new-project', args=[team.slug]))

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

    return render_to_response('sentry/teams/new.html', context, request)
Esempio n. 3
0
def create_new_team(request):
    if not can_create_teams(request.user):
        return missing_perm(request, Permissions.ADD_TEAM)

    if request.user.has_perm('sentry.can_add_team'):
        form_cls = NewTeamAdminForm
        initial = {
            'owner': request.user.username,
        }
    else:
        form_cls = NewTeamForm
        initial = {}

    form = form_cls(request.POST or None, initial=initial)
    if form.is_valid():
        team = form.save(commit=False)
        if not team.owner_id:
            team.owner = request.user
        team.save()
        return HttpResponseRedirect(
            reverse('sentry-new-project', args=[team.slug]))

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

    return render_to_response('sentry/teams/new.html', context, request)
Esempio n. 4
0
def create_new_team_project(request, team):
    from sentry.web.forms.projects import NewProjectAdminForm, NewProjectForm

    if not can_create_projects(request.user, team):
        return missing_perm(request, Permissions.ADD_PROJECT, team=team)

    if request.user.has_perm('sentry.can_add_project'):
        form_cls = NewProjectAdminForm
        initial = {
            'owner': request.user.username,
        }
    else:
        form_cls = NewProjectForm
        initial = {}

    form = form_cls(request.POST or None, initial=initial)
    if form.is_valid():
        project = form.save(commit=False)
        project.team = team
        if not project.owner:
            project.owner = request.user
        project.save()

        if project.platform not in (None, 'other'):
            return HttpResponseRedirect(reverse('sentry-docs-client', args=[project.team.slug, project.slug, project.platform]))
        return HttpResponseRedirect(reverse('sentry-get-started', args=[project.team.slug, project.slug]))

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

    return render_with_team_context(team, 'sentry/teams/projects/new.html', context, request)
Esempio n. 5
0
    def handle(self, request, organization):
        if not can_add_organization_member(request.user, organization):
            return missing_perm(request, Permissions.ADD_MEMBER, organization=organization)

        form = self.get_form(request)
        if form.is_valid():
            om, created = form.save(request.user, organization, request.META['REMOTE_ADDR'])

            if created:
                messages.add_message(request, messages.SUCCESS,
                    _('The organization member was added.'))
            else:
                messages.add_message(request, messages.INFO,
                    _('The organization member already exists.'))

            redirect = reverse('sentry-organization-member-settings',
                               args=[organization.slug, om.id])

            return HttpResponseRedirect(redirect)

        context = {
            'form': form,
            'is_invite': settings.SENTRY_ENABLE_INVITES,
        }

        return self.respond('sentry/create-organization-member.html', context)
Esempio n. 6
0
    def handle(self, request, organization):
        if not can_create_teams(request.user, organization):
            return missing_perm(request, Permissions.ADD_TEAM)

        session_data = request.session.get(self.session_key, {})
        if request.method == 'GET':
            logging.debug('GET request; resetting create team form wizard')
            current_step = 0
            try:
                del request.session[self.session_key]
            except KeyError:
                pass
        else:
            current_step = int(request.POST.get('step', 0))

        last_step = len(self.steps) - 1

        if current_step > last_step:
            logging.debug(
                'Invalid step passed; resetting create team form wizard')
            return self.render_validation_error(request, organization)

        op = request.POST.get('op')
        if op != 'continue':
            data = None
        else:
            data = request.POST or None

        form = self.get_step_form(current_step, data)
        if op == 'continue' and form.is_valid():
            session_data['step%d' % current_step] = form.cleaned_data
            request.session[self.session_key] = session_data
            if current_step == last_step:
                # no more steps, render done view
                return self.render_done(request, organization, form)
            else:
                # proceed to the next step
                return self.render_next_step(request, organization,
                                             current_step + 1)

        elif op == 'back' and current_step > 0:
            return self.render_next_step(request, organization,
                                         current_step - 1)

        elif op == 'skip' and current_step > 0:
            session_data['step%d' % current_step] = {}
            request.session[self.session_key] = session_data
            if current_step == last_step:
                # no more steps, render done view
                return self.render_done(request, organization, form)
            else:
                # proceed to the next step
                return self.render_next_step(request, organization,
                                             current_step + 1)

        return self.render(request, organization, current_step, form)
Esempio n. 7
0
    def handle(self, request, organization):
        if not can_create_teams(request.user, organization):
            return missing_perm(request, Permissions.ADD_TEAM)

        session_data = request.session.get(self.session_key, {})
        if request.method == 'GET':
            logging.debug('GET request; resetting create team form wizard')
            current_step = 0
            try:
                del request.session[self.session_key]
            except KeyError:
                pass
        else:
            current_step = int(request.POST.get('step', 0))

        last_step = len(self.steps) - 1

        if current_step > last_step:
            logging.debug('Invalid step passed; resetting create team form wizard')
            return self.render_validation_error(request, organization)

        op = request.POST.get('op')
        if op != 'continue':
            data = None
        else:
            data = request.POST or None

        form = self.get_step_form(current_step, data)
        if op == 'continue' and form.is_valid():
            session_data['step%d' % current_step] = form.cleaned_data
            request.session[self.session_key] = session_data
            if current_step == last_step:
                # no more steps, render done view
                return self.render_done(request, organization, form)
            else:
                # proceed to the next step
                return self.render_next_step(request, organization, current_step + 1)

        elif op == 'back' and current_step > 0:
            return self.render_next_step(request, organization, current_step - 1)

        elif op == 'skip' and current_step > 0:
            session_data['step%d' % current_step] = {}
            request.session[self.session_key] = session_data
            if current_step == last_step:
                # no more steps, render done view
                return self.render_done(request, organization, form)
            else:
                # proceed to the next step
                return self.render_next_step(request, organization, current_step + 1)

        return self.render(request, organization, current_step, form)