From fc3298865c094200dc7802027e293022b3798482 Mon Sep 17 00:00:00 2001 From: Hubert Jankowski Date: Tue, 25 Jan 2022 18:01:26 +0100 Subject: [PATCH] Remove test --- templates/deletedTest.html | 4 ++++ templates/myTests.html | 2 +- trials/urls.py | 3 ++- trials/views.py | 7 +++++-- 4 files changed, 12 insertions(+), 4 deletions(-) create mode 100644 templates/deletedTest.html diff --git a/templates/deletedTest.html b/templates/deletedTest.html new file mode 100644 index 0000000..baf3f6c --- /dev/null +++ b/templates/deletedTest.html @@ -0,0 +1,4 @@ +Usunąłeś test! + + +Home \ No newline at end of file diff --git a/templates/myTests.html b/templates/myTests.html index 5e8e378..ee93350 100644 --- a/templates/myTests.html +++ b/templates/myTests.html @@ -21,7 +21,7 @@
- +

diff --git a/trials/urls.py b/trials/urls.py index d9c40fc..60d6d00 100644 --- a/trials/urls.py +++ b/trials/urls.py @@ -14,7 +14,8 @@ urlpatterns = [ path('/mark', TestValidateAPIView.as_view()), path('/result', TestResultView.as_view()), path('/edit', EditTestTemplateView.as_view()), - path('delete', deleteTest, name="deleteTest"), + path('/remove', deleteTest, name = "deleteTest"), + # path('delete', deleteTest, name="deleteTest"), path('add/test', addTest, name="newTest"), path('add/questions', addQuestions, name="addQuestions"), path('my', myTests, name="myTests"), diff --git a/trials/views.py b/trials/views.py index d34b65a..b4c57bc 100644 --- a/trials/views.py +++ b/trials/views.py @@ -158,8 +158,11 @@ class EditTestTemplateView(TemplateView): template = get_template(template_name) return HttpResponse(template.render(context)) -def deleteTest(TemplateView): - pass +def deleteTest(request, test_id): + Test.objects.filter(id=test_id).delete() + return render(request, 'deletedTest.html') + + class TestModelViewSet(viewsets.ModelViewSet): -- 2.20.1