diff --git a/templates/canNotEditTest.html b/templates/canNotEditTest.html new file mode 100644 index 0000000..ddfde9b --- /dev/null +++ b/templates/canNotEditTest.html @@ -0,0 +1,3 @@ +Nie możesz edydotwać testu stworzonego przez innego użytkownika + + \ No newline at end of file diff --git a/trials/views.py b/trials/views.py index 23d7bbe..1d0171f 100644 --- a/trials/views.py +++ b/trials/views.py @@ -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):