Python horizon.forms.CheckboxInput() Examples

The following are 3 code examples of horizon.forms.CheckboxInput(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module horizon.forms , or try the search function .
Example #1
Source File: workflows.py    From networking-bgpvpn with Apache License 2.0 5 votes vote down vote up
def __init__(self, request, context, *args, **kwargs):
        super(CreateRouterAssociationInfoAction, self).__init__(
            request, context, *args, **kwargs)

        # when an admin user uses the project panel BGPVPN, there is no
        # tenant_id in context because bgpvpn_get doesn't return it
        if request.user.is_superuser and context.get("project_id"):
            tenant_id = context.get("project_id")
        else:
            tenant_id = self.request.user.tenant_id

        try:
            routers = api.neutron.router_list(request, tenant_id=tenant_id)
            if routers:
                choices = [('', _("Choose a router"))] + [(r.id, r) for r in
                                                          routers]
                self.fields['router_resource'].choices = choices
            else:
                self.fields['router_resource'].choices = [('', _("No router"))]
        except Exception:
            exceptions.handle(request, _("Unable to retrieve routers"))

        if api.neutron.is_extension_supported(request,
                                              'bgpvpn-routes-control'):
            self.fields['with_parameters'] = forms.BooleanField(
                label=_("Optional parameters"),
                initial=False,
                required=False,
                widget=forms.CheckboxInput(attrs={
                    'class': 'switchable',
                    'data-hide-tab': 'router_association__'
                                     'add_router_parameters',
                    'data-hide-on-checked': 'false'
                })) 
Example #2
Source File: forms.py    From avos with Apache License 2.0 5 votes vote down vote up
def __init__(self, request, *args, **kwargs):
        super(UpdateImageForm, self).__init__(request, *args, **kwargs)
        self.fields['disk_format'].choices = [(value, name) for value,
                                              name in IMAGE_FORMAT_CHOICES
                                              if value]
        if not policy.check((("image", "publicize_image"),), request):
            self.fields['public'].widget = forms.CheckboxInput(
                attrs={'readonly': 'readonly'}) 
Example #3
Source File: workflow_helpers.py    From avos with Apache License 2.0 5 votes vote down vote up
def build_control(parameter):
    attrs = {"priority": parameter.priority,
             "placeholder": parameter.default_value}
    if parameter.param_type == "string":
        return forms.CharField(
            widget=forms.TextInput(attrs=attrs),
            label=parameter.name,
            required=(parameter.required and
                      parameter.default_value is None),
            help_text=parameter.description,
            initial=parameter.initial_value)

    if parameter.param_type == "int":
        return forms.IntegerField(
            widget=forms.TextInput(attrs=attrs),
            label=parameter.name,
            required=parameter.required,
            help_text=parameter.description,
            initial=parameter.initial_value)

    elif parameter.param_type == "bool":
        return forms.BooleanField(
            widget=forms.CheckboxInput(attrs=attrs),
            label=parameter.name,
            required=False,
            initial=parameter.initial_value,
            help_text=parameter.description)

    elif parameter.param_type == "dropdown":
        return forms.ChoiceField(
            widget=forms.Select(attrs=attrs),
            label=parameter.name,
            required=parameter.required,
            choices=parameter.choices,
            help_text=parameter.description)