Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Jan 1, 2023
1 parent b0546a0 commit dd3d71e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
11 changes: 7 additions & 4 deletions project/tests/test_delete_request.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
from http import HTTPStatus

from django.test import Client, TestCase
from silk.models import Request
from django.urls import reverse
from http import HTTPStatus

from silk.models import Request


class TestDeleteRequest(TestCase):
def setUp(self):
Expand All @@ -11,7 +14,7 @@ def setUp(self):
self.request.method = 'get'
self.request.body = b'a' * 1000
self.request.save()

def test_delete(self):
response = self.client.post(reverse('silk:request_detail', kwargs={'request_id':str(self.request.id)}))
response = self.client.post(reverse('silk:request_detail', kwargs={'request_id': str(self.request.id)}))
self.assertEqual(response.status_code, HTTPStatus.FOUND)
6 changes: 3 additions & 3 deletions silk/views/request_detail.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import json

from django.shortcuts import render, redirect, HttpResponseRedirect
from django.shortcuts import HttpResponseRedirect, redirect, render
from django.utils.decorators import method_decorator
from django.views.generic import View

Expand Down Expand Up @@ -40,13 +40,13 @@ def get(self, request, request_id):
'request': request
}
return render(request, 'silk/request.html', context)

@method_decorator(login_possibly_required)
@method_decorator(permissions_possibly_required)
def post(self, request, request_id):
silk_request = Request.objects.get(pk=request_id)
try:
silk_request.delete()
except Request.DoesNotExist:
return HttpResponseRedirect(request.META.get('HTTP_REFERER', '/silk'))
return HttpResponseRedirect(request.headers.get('Referer', '/silk'))
return redirect('/silk')

0 comments on commit dd3d71e

Please sign in to comment.