本文整理汇总了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
示例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
)
示例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"))
示例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."))
示例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)
示例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)
示例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])
示例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
示例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)
示例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)
示例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))
示例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)
示例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)
示例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())
示例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
)