Esempio n. 1
0
def edit_project_key(request, team, project, key_id):
    if not can_edit_project_key(request.user, project):
        return HttpResponseRedirect(reverse('sentry-manage-project-keys', args=[project.team.slug, project.slug]))

    try:
        key = ProjectKey.objects.get(
            id=key_id,
            project=project,
        )
    except ProjectKey.DoesNotExist():
        return HttpResponseRedirect(reverse('sentry-manage-project-keys', args=[project.team.slug, project.slug]))

    form = EditProjectKeyForm(request.POST or None, instance=key)
    if form.is_valid():
        form.save()

        messages.add_message(
            request, messages.SUCCESS, _('Changes to your API key were saved.'))
        return HttpResponseRedirect(reverse('sentry-manage-project-keys', args=[project.team.slug, project.slug]))

    context = {
        'team': team,
        'project': project,
        'page': 'keys',
        'key': key,
        'form': form,
    }

    return render_to_response('sentry/projects/edit_key.html', context, request)
Esempio n. 2
0
    def handle(self, request, organization, team, project, key_id):
        try:
            key = ProjectKey.objects.get(
                id=key_id,
                project=project,
            )
        except ProjectKey.DoesNotExist:
            return self.redirect(reverse('sentry-manage-project-keys', args=[project.organization.slug, project.slug]))

        form = EditProjectKeyForm(request.POST or None, instance=key)
        if form.is_valid():
            key = form.save()

            self.create_audit_entry(
                request,
                organization=organization,
                target_object=key.id,
                event=AuditLogEntryEvent.PROJECTKEY_EDIT,
                data=key.get_audit_log_data(),
            )

            messages.add_message(
                request, messages.SUCCESS,
                _('Changes to the API key (%s) were saved.') % (key.public_key,))
            return self.redirect(reverse('sentry-manage-project-keys', args=[project.organization.slug, project.slug]))

        context = {
            'page': 'keys',
            'key': key,
            'form': form,
        }

        return self.respond('sentry/projects/edit_key.html', context)
Esempio n. 3
0
def edit_project_key(request, organization, project, key_id):
    try:
        key = ProjectKey.objects.get(
            id=key_id,
            project=project,
        )
    except ProjectKey.DoesNotExist():
        return HttpResponseRedirect(
            reverse('sentry-manage-project-keys',
                    args=[project.organization.slug, project.slug]))

    if not can_edit_project_key(request.user, key):
        return HttpResponseRedirect(
            reverse('sentry-manage-project-keys',
                    args=[project.organization.slug, project.slug]))

    form = EditProjectKeyForm(request.POST or None, instance=key)
    if form.is_valid():
        key = form.save()

        AuditLogEntry.objects.create(
            organization=organization,
            actor=request.user,
            ip_address=request.META['REMOTE_ADDR'],
            target_object=key.id,
            event=AuditLogEntryEvent.PROJECTKEY_EDIT,
            data=key.get_audit_log_data(),
        )

        messages.add_message(
            request, messages.SUCCESS,
            _('Changes to the API key (%s) were saved.') % (key.public_key, ))
        return HttpResponseRedirect(
            reverse('sentry-manage-project-keys',
                    args=[project.organization.slug, project.slug]))

    context = {
        'organization': organization,
        'team': project.team,
        'project': project,
        'page': 'keys',
        'key': key,
        'form': form,
    }

    return render_to_response('sentry/projects/edit_key.html', context,
                              request)
Esempio n. 4
0
def edit_project_key(request, organization, project, key_id):
    try:
        key = ProjectKey.objects.get(id=key_id, project=project)
    except ProjectKey.DoesNotExist():
        return HttpResponseRedirect(
            reverse("sentry-manage-project-keys", args=[project.organization.slug, project.slug])
        )

    if not can_edit_project_key(request.user, key):
        return HttpResponseRedirect(
            reverse("sentry-manage-project-keys", args=[project.organization.slug, project.slug])
        )

    form = EditProjectKeyForm(request.POST or None, instance=key)
    if form.is_valid():
        key = form.save()

        AuditLogEntry.objects.create(
            organization=organization,
            actor=request.user,
            ip_address=request.META["REMOTE_ADDR"],
            target_object=key.id,
            event=AuditLogEntryEvent.PROJECTKEY_EDIT,
            data=key.get_audit_log_data(),
        )

        messages.add_message(
            request, messages.SUCCESS, _("Changes to the API key (%s) were saved.") % (key.public_key,)
        )
        return HttpResponseRedirect(
            reverse("sentry-manage-project-keys", args=[project.organization.slug, project.slug])
        )

    context = {
        "organization": organization,
        "team": project.team,
        "project": project,
        "page": "keys",
        "key": key,
        "form": form,
    }

    return render_to_response("sentry/projects/edit_key.html", context, request)
Esempio n. 5
0
    def handle(self, request, organization, team, project, key_id):
        try:
            key = ProjectKey.objects.get(
                id=key_id,
                project=project,
            )
        except ProjectKey.DoesNotExist:
            return self.redirect(
                reverse('sentry-manage-project-keys',
                        args=[project.organization.slug, project.slug]))

        form = EditProjectKeyForm(request.POST or None, instance=key)
        if form.is_valid():
            key = form.save()

            self.create_audit_entry(
                request,
                organization=organization,
                target_object=key.id,
                event=AuditLogEntryEvent.PROJECTKEY_EDIT,
                data=key.get_audit_log_data(),
            )

            messages.add_message(
                request, messages.SUCCESS,
                _('Changes to the API key (%s) were saved.') %
                (key.public_key, ))
            return self.redirect(
                reverse('sentry-manage-project-keys',
                        args=[project.organization.slug, project.slug]))

        context = {
            'page': 'keys',
            'key': key,
            'form': form,
        }

        return self.respond('sentry/projects/edit_key.html', context)
Esempio n. 6
0
def edit_project_key(request, organization, project, key_id):
    if not can_edit_project_key(request.user, project):
        return HttpResponseRedirect(
            reverse('sentry-manage-project-keys',
                    args=[project.organization.slug, project.slug]))

    try:
        key = ProjectKey.objects.get(
            id=key_id,
            project=project,
        )
    except ProjectKey.DoesNotExist():
        return HttpResponseRedirect(
            reverse('sentry-manage-project-keys',
                    args=[project.organization.slug, project.slug]))

    form = EditProjectKeyForm(request.POST or None, instance=key)
    if form.is_valid():
        form.save()

        messages.add_message(request, messages.SUCCESS,
                             _('Changes to your API key were saved.'))
        return HttpResponseRedirect(
            reverse('sentry-manage-project-keys',
                    args=[project.organization.slug, project.slug]))

    context = {
        'organization': organization,
        'team': project.team,
        'project': project,
        'page': 'keys',
        'key': key,
        'form': form,
    }

    return render_to_response('sentry/projects/edit_key.html', context,
                              request)
Esempio n. 7
0
def edit_project_key(request, organization, project, key_id):
    try:
        key = ProjectKey.objects.get(
            id=key_id,
            project=project,
        )
    except ProjectKey.DoesNotExist():
        return HttpResponseRedirect(reverse('sentry-manage-project-keys', args=[project.organization.slug, project.slug]))

    form = EditProjectKeyForm(request.POST or None, instance=key)
    if form.is_valid():
        key = form.save()

        AuditLogEntry.objects.create(
            organization=organization,
            actor=request.user,
            ip_address=request.META['REMOTE_ADDR'],
            target_object=key.id,
            event=AuditLogEntryEvent.PROJECTKEY_EDIT,
            data=key.get_audit_log_data(),
        )

        messages.add_message(
            request, messages.SUCCESS,
            _('Changes to the API key (%s) were saved.') % (key.public_key,))
        return HttpResponseRedirect(reverse('sentry-manage-project-keys', args=[project.organization.slug, project.slug]))

    context = {
        'organization': organization,
        'team': project.team,
        'project': project,
        'page': 'keys',
        'key': key,
        'form': form,
    }

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