Commit 931ef81c by Kálmán Viktor

dashboard: fix lease delete tests

parent 75442927
...@@ -299,7 +299,7 @@ class VmDetailTest(LoginMixin, TestCase): ...@@ -299,7 +299,7 @@ class VmDetailTest(LoginMixin, TestCase):
leases = Lease.objects.count() leases = Lease.objects.count()
response = c.post("/dashboard/lease/delete/1/") response = c.post("/dashboard/lease/delete/1/")
# redirect to the login page # redirect to the login page
self.assertEqual(response.status_code, 302) self.assertEqual(response.status_code, 403)
self.assertEqual(leases, Lease.objects.count()) self.assertEqual(leases, Lease.objects.count())
def test_notification_read(self): def test_notification_read(self):
......
...@@ -471,10 +471,9 @@ class LeaseDelete(LoginRequiredMixin, DeleteView): ...@@ -471,10 +471,9 @@ class LeaseDelete(LoginRequiredMixin, DeleteView):
def delete(self, request, *args, **kwargs): def delete(self, request, *args, **kwargs):
object = self.get_object() object = self.get_object()
# if there are still templates with this lease if not object.has_level(request.user, "owner"):
# or the user is not owner raise PermissionDenied()
if (object.instancetemplate_set.count() > 0 if object.instancetemplate_set.count() > 0:
or not object.has_level(request.user, "owner")):
raise SuspiciousOperation() raise SuspiciousOperation()
object.delete() object.delete()
......
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