block edit someone else test #33
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
|
||||
context = super().get_context_data(**kwargs)
|
||||
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
|
||||
|
||||
def post(self, request, *args, **kwargs):
|
||||
|
Loading…
Reference in New Issue
Block a user