当前位置: 首页>>代码示例>>Python>>正文


Python forms.CharField方法代码示例

本文整理汇总了Python中horizon.forms.CharField方法的典型用法代码示例。如果您正苦于以下问题:Python forms.CharField方法的具体用法?Python forms.CharField怎么用?Python forms.CharField使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在horizon.forms的用法示例。


在下文中一共展示了forms.CharField方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __init__

# 需要导入模块: from horizon import forms [as 别名]
# 或者: from horizon.forms import CharField [as 别名]
def __init__(self, request, *args, **kwargs):
        super(ClientsConfigurationAction, self).__init__(request,
                                                         *args,
                                                         **kwargs)
        err_msg = _('Unable to retrieve client list.')

        job_id = args[0].get('job_id', None)

        default_role_name = self.get_default_role_field_name()
        self.fields[default_role_name] = forms.CharField(required=False)
        self.fields[default_role_name].initial = 'member'

        all_clients = []
        try:
            all_clients = freezer_api.Client(request).list()
        except Exception:
            exceptions.handle(request, err_msg)
        client_list = [(c.uuid, c.hostname)
                       for c in all_clients]

        field_name = self.get_member_field_name('member')
        if not job_id:
            self.fields[field_name] = forms.MultipleChoiceField()
            self.fields[field_name].choices = client_list 
开发者ID:openstack,项目名称:freezer-web-ui,代码行数:26,代码来源:create.py

示例2: __init__

# 需要导入模块: from horizon import forms [as 别名]
# 或者: from horizon.forms import CharField [as 别名]
def __init__(self, request, *args, **kwargs):
        super(GeneralConfigAction, self).__init__(request, *args, **kwargs)

        plugin, hadoop_version = whelpers.\
            get_plugin_and_hadoop_version(request)

        if saharaclient.base.is_service_enabled(request, 'network'):
            self.fields["neutron_management_network"] = forms.ChoiceField(
                label=_("Neutron Management Network"),
                choices=self.populate_neutron_management_network_choices(
                    request, {})
            )

        self.fields["plugin_name"] = forms.CharField(
            widget=forms.HiddenInput(),
            initial=plugin
        )
        self.fields["hadoop_version"] = forms.CharField(
            widget=forms.HiddenInput(),
            initial=hadoop_version
        ) 
开发者ID:CiscoSystems,项目名称:avos,代码行数:23,代码来源:create.py

示例3: __init__

# 需要导入模块: from horizon import forms [as 别名]
# 或者: from horizon.forms import CharField [as 别名]
def __init__(self, request, *args, **kwargs):
        super(CreateFieldForm, self).__init__(request, *args, **kwargs)
        service_id = kwargs['initial']['service_id']
        manager = api.cloudkittyclient(request).rating.hashmap
        service = manager.get_service(service_id=service_id)
        self.fields['service_name'].initial = service['name']

        try:
            fields = manager.get_field(service_id=service['name'])['fields']
        except exceptions.NotFound:
            fields = None
        if fields:
            fields = api.identify(fields)
            choices = sorted([(field, field) for field in fields['metadata']])
            self.fields['field'] = forms.DynamicChoiceField(
                label=_("Field"))
            self.fields['field'].choices = choices
        else:
            self.fields['field'] = forms.CharField(
                label=_("Field")) 
开发者ID:openstack,项目名称:cloudkitty-dashboard,代码行数:22,代码来源:forms.py

示例4: _init_fields

# 需要导入模块: from horizon import forms [as 别名]
# 或者: from horizon.forms import CharField [as 别名]
def _init_fields(self, readOnly=False, create=False):
        required = True
        textWidget = None
        selectWidget = None
        readOnlyTextInput = READONLY_TEXTINPUT
        readOnlySelectInput = forms.Select(attrs={'disabled': 'disabled'})
        if readOnly:
            required = False
            textWidget = readOnlyTextInput
            selectWidget = readOnlySelectInput

        choices = [(n['type'], n['type'].capitalize()) for n in self.notification_types]
        choices = sorted(choices, key=lambda c: c[0])
        period_choices = [(0, '0'), (60, '60')]

        self.fields['name'] = forms.CharField(label=_("Name"),
                                              required=required,
                                              max_length="250",
                                              widget=textWidget,
                                              help_text=_("A descriptive name of "
                                                          "the notification method."))
        self.fields['type'] = forms.ChoiceField(
            label=_("Type"),
            required=required,
            widget=selectWidget,
            choices=choices,
            initial=constants.NotificationType.EMAIL,
            help_text=_("The type of notification method (i.e. email)."))
        self.fields['address'] = forms.CharField(label=_("Address"),
                                                 required=required,
                                                 max_length="512",
                                                 widget=textWidget,
                                                 help_text=_("The email/url address to notify."))
        self.fields['period'] = forms.ChoiceField(label=_("Period"),
                                                  widget=selectWidget,
                                                  choices=period_choices,
                                                  initial=0,
                                                  required=required,
                                                  help_text=_("The notification period.")) 
开发者ID:openstack,项目名称:monasca-ui,代码行数:41,代码来源:forms.py

示例5: _init_fields

# 需要导入模块: from horizon import forms [as 别名]
# 或者: from horizon.forms import CharField [as 别名]
def _init_fields(self, readOnly=False, create=False, initial=None):
        required = True
        textWidget = None
        textAreaWidget = forms.Textarea(attrs={'class': 'large-text-area'})
        choiceWidget = forms.Select
        if create:
            expressionWidget = SimpleExpressionWidget(initial)
            notificationWidget = NotificationCreateWidget()
        else:
            expressionWidget = textAreaWidget
            notificationWidget = NotificationCreateWidget()

        self.fields['name'] = forms.CharField(label=_("Name"),
                                              required=required,
                                              max_length=250,
                                              widget=textWidget)
        self.fields['expression'] = forms.CharField(label=_("Expression"),
                                                    required=required,
                                                    widget=expressionWidget)
        self.fields['description'] = forms.CharField(label=_("Description"),
                                                     required=False,
                                                     widget=textAreaWidget)
        sev_choices = [("LOW", _("Low")),
                       ("MEDIUM", _("Medium")),
                       ("HIGH", _("High")),
                       ("CRITICAL", _("Critical"))]
        self.fields['severity'] = forms.ChoiceField(label=_("Severity"),
                                                    choices=sev_choices,
                                                    widget=choiceWidget,
                                                    required=False)
        self.fields['state'] = forms.CharField(label=_("State"),
                                               required=False,
                                               widget=textWidget)
        self.fields['actions_enabled'] = \
            forms.BooleanField(label=_("Notifications Enabled"),
                               required=False,
                               initial=True)
        self.fields['notifications'] = NotificationField(
            label=_("Notifications"),
            required=False,
            widget=notificationWidget) 
开发者ID:openstack,项目名称:monasca-ui,代码行数:43,代码来源:forms.py

示例6: __init__

# 需要导入模块: from horizon import forms [as 别名]
# 或者: from horizon.forms import CharField [as 别名]
def __init__(self, request, *args, **kwargs):
        super(self.__class__, self).__init__(request, *args, **kwargs)
        # populate share_id
        share_id = kwargs.get('initial', {}).get('share_id', [])
        self.fields['share_id'] = forms.CharField(
            widget=forms.HiddenInput(), initial=share_id) 
开发者ID:openstack,项目名称:manila-ui,代码行数:8,代码来源:forms.py

示例7: __init__

# 需要导入模块: from horizon import forms [as 别名]
# 或者: from horizon.forms import CharField [as 别名]
def __init__(self, request, *args, **kwargs):
        super(CreateReplicaForm, self).__init__(request, *args, **kwargs)

        # populate share_id
        share_id = kwargs.get('initial', {}).get('share_id', [])
        self.fields['share_id'] = forms.CharField(widget=forms.HiddenInput(),
                                                  initial=share_id)

        availability_zones = manila.availability_zone_list(request)
        self.fields['availability_zone'].choices = (
            [(az.name, az.name) for az in availability_zones]) 
开发者ID:openstack,项目名称:manila-ui,代码行数:13,代码来源:forms.py

示例8: __init__

# 需要导入模块: from horizon import forms [as 别名]
# 或者: from horizon.forms import CharField [as 别名]
def __init__(self, request, *args, **kwargs):
        super(AddSecurityServiceAction, self).__init__(request,
                                                       *args,
                                                       **kwargs)
        err_msg = _('Unable to get the security services hosts')

        default_role_field_name = self.get_default_role_field_name()
        self.fields[default_role_field_name] = forms.CharField(required=False)
        self.fields[default_role_field_name].initial = 'member'

        field_name = self.get_member_field_name('member')
        self.fields[field_name] = forms.MultipleChoiceField(required=False)

        share_network_id = self.initial['id']
        security_services = manila.share_network_security_service_list(
            request, share_network_id)
        sec_services_initial = [sec_service.id for sec_service
                                in security_services]
        sec_services = []
        try:
            sec_services = manila.security_service_list(request)
        except Exception:
            exceptions.handle(request, err_msg)

        sec_services_choices = [(sec_service.id,
                                 sec_service.name or sec_service.id)
                                for sec_service in sec_services]
        self.fields[field_name].choices = sec_services_choices
        self.fields[field_name].initial = sec_services_initial 
开发者ID:openstack,项目名称:manila-ui,代码行数:31,代码来源:workflows.py

示例9: __init__

# 需要导入模块: from horizon import forms [as 别名]
# 或者: from horizon.forms import CharField [as 别名]
def __init__(self, request, *args, **kwargs):
        super(self.__class__, self).__init__(request, *args, **kwargs)
        # populate share_group_id
        sg_id = kwargs.get('initial', {}).get('share_group_id', [])
        self.fields['share_group_id'] = forms.CharField(
            widget=forms.HiddenInput(), initial=sg_id) 
开发者ID:openstack,项目名称:manila-ui,代码行数:8,代码来源:forms.py

示例10: __init__

# 需要导入模块: from horizon import forms [as 别名]
# 或者: from horizon.forms import CharField [as 别名]
def __init__(self, request, *args, **kwargs):
        super(AddProjectAction, self).__init__(request, *args, **kwargs)
        default_role_field_name = self.get_default_role_field_name()
        self.fields[default_role_field_name] = forms.CharField(required=False)
        self.fields[default_role_field_name].initial = 'member'

        field_name = self.get_member_field_name('member')
        self.fields[field_name] = forms.MultipleChoiceField(required=False)
        share_type_id = self.initial['id']

        # Get list of existing projects
        try:
            projects, __ = keystone.tenant_list(request)
        except Exception:
            err_msg = _('Unable to get list of projects.')
            exceptions.handle(request, err_msg)

        # Get list of projects with access to this Share Type
        try:
            share_type = manila.share_type_get(request, share_type_id)
            self.share_type_name = share_type.name
            projects_initial = manila.share_type_access_list(
                request, share_type)
        except Exception:
            err_msg = _('Unable to get information about share type access.')
            exceptions.handle(request, err_msg)

        self.fields[field_name].choices = [
            (project.id, project.name or project.id) for project in projects]
        self.fields[field_name].initial = [
            pr.project_id for pr in projects_initial]
        self.projects_initial = set(self.fields[field_name].initial) 
开发者ID:openstack,项目名称:manila-ui,代码行数:34,代码来源:workflows.py

示例11: test___init__

# 需要导入模块: from horizon import forms [as 别名]
# 或者: from horizon.forms import CharField [as 别名]
def test___init__(self, extra_specs_dict_input, extra_specs_str_output):
        form = self._get_form({'extra_specs': extra_specs_dict_input})

        for expected_extra_spec in extra_specs_str_output:
            self.assertIn(expected_extra_spec, form.initial['extra_specs'])
        self.assertIn('extra_specs', list(form.fields.keys()))
        self.assertTrue(
            isinstance(form.fields['extra_specs'], horizon_forms.CharField)) 
开发者ID:openstack,项目名称:manila-ui,代码行数:10,代码来源:test_forms.py

示例12: _generate_parameter_fields

# 需要导入模块: from horizon import forms [as 别名]
# 或者: from horizon.forms import CharField [as 别名]
def _generate_parameter_fields(self, list):
        self.workflow_parameters = []
        for entry in list.split(","):
            label, _, default = entry.partition("=")
            label = label.strip()
            if label != '':
                self.workflow_parameters.append(label)
                if default == "None":
                    default = None
                    required = False
                else:
                    required = True
                self.fields[label] = forms.CharField(label=label,
                                                     required=required,
                                                     initial=default) 
开发者ID:openstack,项目名称:mistral-dashboard,代码行数:17,代码来源:forms.py

示例13: build_control

# 需要导入模块: from horizon import forms [as 别名]
# 或者: from horizon.forms import CharField [as 别名]
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) 
开发者ID:CiscoSystems,项目名称:avos,代码行数:37,代码来源:workflow_helpers.py

示例14: build_node_group_fields

# 需要导入模块: from horizon import forms [as 别名]
# 或者: from horizon.forms import CharField [as 别名]
def build_node_group_fields(action, name, template, count, serialized=None):
    action.fields[name] = forms.CharField(
        label=_("Name"),
        widget=forms.TextInput())

    action.fields[template] = forms.CharField(
        label=_("Node group cluster"),
        widget=forms.HiddenInput())

    action.fields[count] = forms.IntegerField(
        label=_("Count"),
        min_value=0,
        widget=forms.HiddenInput())
    action.fields[serialized] = forms.CharField(
        widget=forms.HiddenInput()) 
开发者ID:CiscoSystems,项目名称:avos,代码行数:17,代码来源:workflow_helpers.py

示例15: __init__

# 需要导入模块: from horizon import forms [as 别名]
# 或者: from horizon.forms import CharField [as 别名]
def __init__(self, request, *args, **kwargs):
        super(GeneralConfigAction, self).__init__(request, *args, **kwargs)
        plugin, hadoop_version = whelpers.\
            get_plugin_and_hadoop_version(request)

        self.fields["plugin_name"] = forms.CharField(
            widget=forms.HiddenInput(),
            initial=plugin
        )
        self.fields["hadoop_version"] = forms.CharField(
            widget=forms.HiddenInput(),
            initial=hadoop_version
        ) 
开发者ID:CiscoSystems,项目名称:avos,代码行数:15,代码来源:create.py


注:本文中的horizon.forms.CharField方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。