Commit 0ae68ec4 by Kálmán Viktor

dashboard: add network acl to templates

parent fdb2cc34
......@@ -936,7 +936,8 @@ class TemplateCreate(SuccessMessageMixin, CreateView):
post = form.cleaned_data
networks = self.__create_networks(post.pop("networks"))
networks = self.__create_networks(post.pop("networks"),
parent_type = post.pop("parent_type")
post['max_ram_size'] = post['ram_size']
......@@ -970,9 +971,11 @@ class TemplateCreate(SuccessMessageMixin, CreateView):
return super(TemplateCreate, self).post(self, request, args, kwargs)
def __create_networks(self, vlans):
def __create_networks(self, vlans, user):
networks = []
for v in vlans:
if not v.has_level(user, "user"):
raise PermissionDenied()
networks.append(InterfaceTemplate(vlan=v, managed=v.managed))
return networks
......@@ -1037,6 +1040,9 @@ class TemplateDetail(LoginRequiredMixin, SuccessMessageMixin, UpdateView):
for disk in self.get_object().disks.all():
if not disk.has_level(request.user, 'user'):
raise PermissionDenied()
for network in self.get_object().interface_set.all():
if not network.vlan.has_level(request.user, "user"):
raise PermissionDenied()
return super(TemplateDetail, self).post(self, request, args, kwargs)
def get_form_kwargs(self):
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