Commit 75b63279 by Kálmán Viktor

dashboard: 404 for non existing templates

parent 5adcd0d9
......@@ -524,6 +524,12 @@ class VmDetailTest(LoginMixin, TestCase):
self.assertEqual(response.status_code, 403)
self.assertEqual(inst.status, 'SUSPENDED')
def test_non_existing_template_get(self):
c = Client()
self.login(c, "superuser")
response = c.get("/dashboard/template/111111/")
self.assertEqual(response.status_code, 404)
class VmDetailVncTest(LoginMixin, TestCase):
fixtures = ['test-vm-fixture.json', 'node.json']
......@@ -801,7 +801,7 @@ class TemplateDetail(LoginRequiredMixin, SuccessMessageMixin, UpdateView):
success_message = _("Successfully modified template!")
def get(self, request, *args, **kwargs):
template = InstanceTemplate.objects.get(pk=kwargs['pk'])
template = self.get_object()
if not template.has_level(request.user, 'user'):
raise PermissionDenied()
if request.is_ajax():
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment