block edit someone else test
This commit is contained in:
parent
5b8fde0e1c
commit
cbe3e3532a
3
templates/canNotEditTest.html
Normal file
3
templates/canNotEditTest.html
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
Nie możesz edydotwać testu stworzonego przez innego użytkownika
|
||||||
|
|
||||||
|
<input type=button value="Powrót do porzpedniej strony" onClick="javascript:history.go(-1);">
|
@ -192,6 +192,8 @@ class EditTestTemplateView(TemplateView):
|
|||||||
self.test_id = test_id
|
self.test_id = test_id
|
||||||
context = super().get_context_data(**kwargs)
|
context = super().get_context_data(**kwargs)
|
||||||
context["test"] = self.get_queryset().filter(id=test_id).prefetch_related("questions__answers").first()
|
context["test"] = self.get_queryset().filter(id=test_id).prefetch_related("questions__answers").first()
|
||||||
|
if context["test"].created_by.email != self.request.user.email:
|
||||||
|
return render(context, "canNotEditTest.html")
|
||||||
return context
|
return context
|
||||||
|
|
||||||
def post(self, request, *args, **kwargs):
|
def post(self, request, *args, **kwargs):
|
||||||
|
Loading…
Reference in New Issue
Block a user