

def __init__(self, request, *args, **kwargs):
    super(UpdateFirewall, self).__init__(request, *args, **kwargs)
    try:
        tenant_id = self.request.user.tenant_id
        policies = api.fwaas.policy_list_for_tenant(request, tenant_id)
        policies = sorted(policies, key=(lambda policy: policy.name))
    except Exception:
        exceptions.handle(request, _('Unable to retrieve policy list.'))
        policies = []
    policy_id = kwargs['initial']['firewall_policy_id']
    policy_name = [p.name for p in policies if (p.id == policy_id)][0]
    firewall_policy_id_choices = [(policy_id, policy_name)]
    for p in policies:
        if (p.id != policy_id):
            firewall_policy_id_choices.append((p.id, p.name_or_id))
    self.fields['firewall_policy_id'].choices = firewall_policy_id_choices

dataset/ETHPy150Open openstack/horizon/openstack_dashboard/dashboards/project/firewalls/forms.py UpdateFirewall.__init__/original