Commit abfafd7a by Szabolcs Gelencser

Show permitted leases only on renew dialog

parent d9ff14e6
......@@ -724,8 +724,15 @@ class VmRenewView(FormOperationMixin, VmOperationView):
template_name = 'dashboard/_vm-renew.html'
def get_form_kwargs(self):
choices = Lease.objects.all() #TODO: filter on permissions
instance = self.get_op().instance
user_role_names = [role["name"] for role in self.request.user.roles]
leases_from_roles = Lease.objects.filter(roles_permitted__role_name__in=user_role_names)
default_lease = Lease.objects.filter(name=settings.DEFAULT_LEASE_NAME)
current_lease = Lease.objects.filter(vmlease__os_server_id=instance.id)
choices = (leases_from_roles | default_lease | current_lease).distinct()
default = VmLease.objects.get(os_server_id=instance.id).lease
# if default and default not in choices:
# choices = (choices.distinct() |
......
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