Remove test

This commit is contained in:
Hubert Jankowski 2022-01-25 18:01:26 +01:00
parent 05751fea96
commit fc3298865c
4 changed files with 12 additions and 4 deletions

View File

@ -0,0 +1,4 @@
Usunąłeś test!
<a href="/home">Home</a>

View File

@ -21,7 +21,7 @@
<div class="tripleButton">
<button><a href="/tests/{{test.id}}/show">Start</a></button>
<button><a href="/tests/{{test.id}}/edit">Edit</a></button>
<button style="background:#FF0000;"><a href="/tests/{{test.id}}/edit">Delete</a></button>
<button style="background:#FF0000;"><a href="/tests/{{test.id}}/remove">Delete</a></button>
</div>
</div>
<br>

View File

@ -14,7 +14,8 @@ urlpatterns = [
path('<int:test_id>/mark', TestValidateAPIView.as_view()),
path('<int:test_id>/result', TestResultView.as_view()),
path('<int:test_id>/edit', EditTestTemplateView.as_view()),
path('delete', deleteTest, name="deleteTest"),
path('<int:test_id>/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"),

View File

@ -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):