Exemplo n.º 1
0
def manage_project_quotas(request, team, project):
    from sentry.quotas.base import Quota

    form = ProjectQuotasForm(project, request.POST or None)

    if form and form.is_valid():
        form.save()

        messages.add_message(request, messages.SUCCESS,
                             _('Your settings were saved successfully.'))

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

    context = {
        'team': team,
        'page': 'quotas',
        # TODO(dcramer): has_quotas is an awful hack
        'has_quotas': type(app.quotas) != Quota,
        'system_quota': app.quotas.get_system_quota(),
        'team_quota': app.quotas.get_team_quota(team),
        'project': project,
        'form': form,
    }
    return render_to_response('sentry/projects/quotas.html', context, request)
Exemplo n.º 2
0
def manage_project_quotas(request, team, project):
    from sentry.quotas.base import Quota

    form = ProjectQuotasForm(project, request.POST or None)

    if form and form.is_valid():
        form.save()

        messages.add_message(
            request, messages.SUCCESS,
            _('Your settings were saved successfully.'))

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

    context = {
        'team': team,
        'page': 'quotas',
        # TODO(dcramer): has_quotas is an awful hack
        'has_quotas': type(app.quotas) != Quota,
        'system_quota': int(app.quotas.get_system_quota()),
        'team_quota': int(app.quotas.get_team_quota(team)),
        'project': project,
        'form': form,
    }
    return render_to_response('sentry/projects/quotas.html', context, request)
def manage_project_quotas(request, organization, project):
    if not features.has('projects:quotas', project, actor=request.user):
        messages.add_message(
            request, messages.ERROR,
            ERR_NO_SSO,
        )
        redirect = reverse('sentry-manage-project',
                           args=[organization.slug, project.slug])
        return HttpResponseRedirect(redirect)

    form = ProjectQuotasForm(project, request.POST or None)

    if form and form.is_valid():
        form.save()

        messages.add_message(
            request, messages.SUCCESS,
            _('Your settings were saved successfully.'))

        return HttpResponseRedirect(reverse('sentry-manage-project-quotas', args=[project.organization.slug, project.slug]))

    context = {
        'organization': organization,
        'team': project.team,
        'page': 'quotas',
        # TODO(dcramer): has_quotas is an awful hack
        'has_quotas': type(app.quotas) != Quota,
        'system_quota': int(app.quotas.get_system_quota()),
        'team_quota': int(app.quotas.get_team_quota(project.team)),
        'project': project,
        'form': form,
    }
    return render_to_response('sentry/projects/quotas.html', context, request)
Exemplo n.º 4
0
    def handle(self, request, organization, team, project):
        if not features.has("projects:quotas", project, actor=request.user):
            messages.add_message(request, messages.ERROR, ERR_NO_SSO)
            redirect = reverse("sentry-manage-project", args=[organization.slug, project.slug])
            return self.redirect(redirect)

        form = ProjectQuotasForm(project, request.POST or None)

        if form and form.is_valid():
            form.save()

            messages.add_message(request, messages.SUCCESS, _("Your settings were saved successfully."))

            return self.redirect(
                reverse("sentry-manage-project-quotas", args=[project.organization.slug, project.slug])
            )

        context = {
            "organization": organization,
            "team": project.team,
            "page": "quotas",
            # TODO(dcramer): has_quotas is an awful hack
            "has_quotas": type(app.quotas) != Quota,
            "system_quota": int(app.quotas.get_system_quota()),
            "team_quota": int(app.quotas.get_team_quota(project.team)),
            "project": project,
            "form": form,
        }
        return self.respond("sentry/projects/quotas.html", context)
Exemplo n.º 5
0
 def test_accepts_percentage(self):
     project = Project(id=1)
     form = ProjectQuotasForm(project, {'per_minute': '50%'})
     assert form.is_valid()
     assert form.cleaned_data['per_minute'] == '50%'
Exemplo n.º 6
0
 def test_discards_0_percent(self):
     project = Project(id=1)
     form = ProjectQuotasForm(project, {'per_minute': '0%'})
     assert form.is_valid()
     assert form.cleaned_data['per_minute'] == '0'
Exemplo n.º 7
0
 def test_accepts_numbers(self):
     project = Project(id=1)
     form = ProjectQuotasForm(project, {'per_minute': '100'})
     assert form.is_valid()
     assert form.cleaned_data['per_minute'] == '100'
Exemplo n.º 8
0
 def test_invalidates_101_percent(self):
     project = Project(id=1)
     form = ProjectQuotasForm(project, {'per_minute': '101%'})
     assert not form.is_valid()
     assert 'per_minute' in form.errors