Commit 79c214d4 by Kálmán Viktor

dashboard: no migrate button for regular users

parent 8f8c512d
...@@ -1041,7 +1041,8 @@ class MassOperationView(OperationView): ...@@ -1041,7 +1041,8 @@ class MassOperationView(OperationView):
return ctx return ctx
def check_auth(self): @classmethod
def check_auth(self, user=None):
pass pass
def get_object(self): def get_object(self):
...@@ -1112,6 +1113,11 @@ class MassMigrationView(MassOperationView): ...@@ -1112,6 +1113,11 @@ class MassMigrationView(MassOperationView):
icon = "truck" icon = "truck"
effect = "info" effect = "info"
@classmethod
def check_auth(self, user=None):
if user and not user.is_superuser:
raise PermissionDenied
def get_context_data(self, **kwargs): def get_context_data(self, **kwargs):
ctx = super(MassMigrationView, self).get_context_data(**kwargs) ctx = super(MassMigrationView, self).get_context_data(**kwargs)
ctx['nodes'] = [n for n in Node.objects.filter(enabled=True) ctx['nodes'] = [n for n in Node.objects.filter(enabled=True)
...@@ -1715,7 +1721,14 @@ class VmList(LoginRequiredMixin, FilterMixin, ListView): ...@@ -1715,7 +1721,14 @@ class VmList(LoginRequiredMixin, FilterMixin, ListView):
def get_context_data(self, *args, **kwargs): def get_context_data(self, *args, **kwargs):
context = super(VmList, self).get_context_data(*args, **kwargs) context = super(VmList, self).get_context_data(*args, **kwargs)
context['ops'] = [v for k, v in vm_mass_ops.iteritems()] context['ops'] = []
for k, v in vm_mass_ops.iteritems():
try:
v.check_auth(user=self.request.user)
except PermissionDenied:
pass
else:
context['ops'].append(v)
context['search_form'] = self.search_form context['search_form'] = self.search_form
return context return context
......
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