Use ThemableSelectWidget for themable

Some places are not using ThemableSelectWidget, so
these select ui is not themable. This patch fix it.

Change-Id: I303a9cf8c6f8f651edf68973a2f5e16a8b04b26d
Closes-bug: #1669696
This commit is contained in:
Kenji Ishii 2017-03-03 17:15:29 +09:00 committed by Akihiro Motoki
parent 4187837434
commit 00173dc3c8
10 changed files with 33 additions and 29 deletions
doc/source/ref
openstack_dashboard/dashboards/project
cgroups
images/images
instances
networks
security_groups
stacks
vpn

@ -58,7 +58,7 @@ A simplified example is as follows::
('cidr', _('CIDR')), ('cidr', _('CIDR')),
('sg', _('Security Group')) ('sg', _('Security Group'))
], ],
widget=forms.Select(attrs={ widget=forms.ThemableSelectWidget(attrs={
'class': 'switchable', 'class': 'switchable',
'data-slug': 'source' 'data-slug': 'source'
}) })
@ -77,7 +77,7 @@ A simplified example is as follows::
security_group = forms.ChoiceField( security_group = forms.ChoiceField(
label=_('Security Group'), label=_('Security Group'),
required=False, required=False,
widget=forms.Select(attrs={ widget=forms.ThemableSelectWidget(attrs={
'class': 'switched', 'class': 'switched',
'data-switch-on': 'source', 'data-switch-on': 'source',
'data-source-sg': _('Security Group') 'data-source-sg': _('Security Group')

@ -62,7 +62,7 @@ class AddCGroupInfoAction(workflows.Action):
availability_zone = forms.ChoiceField( availability_zone = forms.ChoiceField(
label=_("Availability Zone"), label=_("Availability Zone"),
required=False, required=False,
widget=forms.Select( widget=forms.ThemableSelectWidget(
attrs={'class': 'switched', attrs={'class': 'switched',
'data-switch-on': 'source', 'data-switch-on': 'source',
'data-source-no_source_type': _('Availability Zone'), 'data-source-no_source_type': _('Availability Zone'),

@ -123,7 +123,7 @@ class CreateImageForm(CreateParent):
required=False, required=False,
choices=[('url', _('Image Location')), choices=[('url', _('Image Location')),
('file', _('Image File'))], ('file', _('Image File'))],
widget=forms.Select(attrs={ widget=forms.ThemableSelectWidget(attrs={
'class': 'switchable', 'class': 'switchable',
'data-slug': 'source'})) 'data-slug': 'source'}))
image_url_attrs = { image_url_attrs = {

@ -171,6 +171,7 @@ class DecryptPasswordInstanceForm(forms.SelfHandlingForm):
class AttachVolume(forms.SelfHandlingForm): class AttachVolume(forms.SelfHandlingForm):
volume = forms.ChoiceField(label=_("Volume ID"), volume = forms.ChoiceField(label=_("Volume ID"),
widget=forms.ThemableSelectWidget(),
help_text=_("Select a volume to attach " help_text=_("Select a volume to attach "
"to this instance.")) "to this instance."))
device = forms.CharField(label=_("Device Name"), device = forms.CharField(label=_("Device Name"),
@ -230,6 +231,7 @@ class AttachVolume(forms.SelfHandlingForm):
class DetachVolume(forms.SelfHandlingForm): class DetachVolume(forms.SelfHandlingForm):
volume = forms.ChoiceField(label=_("Volume ID"), volume = forms.ChoiceField(label=_("Volume ID"),
widget=forms.ThemableSelectWidget(),
help_text=_("Select a volume to detach " help_text=_("Select a volume to detach "
"from this instance.")) "from this instance."))
instance_id = forms.CharField(widget=forms.HiddenInput()) instance_id = forms.CharField(widget=forms.HiddenInput())

@ -4742,7 +4742,7 @@ class ConsoleManagerTests(helpers.ResetImageAPIVersionMixin, helpers.TestCase):
self.assertEqual(res.status_code, 200) self.assertEqual(res.status_code, 200)
self.assertFalse(form.fields['device'].required) self.assertFalse(form.fields['device'].required)
self.assertIsInstance(form.fields['volume'].widget, self.assertIsInstance(form.fields['volume'].widget,
forms.Select) forms.ThemableSelectWidget)
self.assertTemplateUsed(res, self.assertTemplateUsed(res,
'project/instances/attach_volume.html') 'project/instances/attach_volume.html')
@ -4783,7 +4783,7 @@ class ConsoleManagerTests(helpers.ResetImageAPIVersionMixin, helpers.TestCase):
form = res.context['form'] form = res.context['form']
self.assertIsInstance(form.fields['volume'].widget, self.assertIsInstance(form.fields['volume'].widget,
forms.Select) forms.ThemableSelectWidget)
self.assertEqual(res.status_code, 200) self.assertEqual(res.status_code, 200)
self.assertTemplateUsed(res, self.assertTemplateUsed(res,
'project/instances/detach_volume.html') 'project/instances/detach_volume.html')

@ -59,14 +59,14 @@ class CreatePort(forms.SelfHandlingForm):
choices=[('', _("Unspecified")), choices=[('', _("Unspecified")),
('subnet_id', _("Subnet")), ('subnet_id', _("Subnet")),
('fixed_ip', _("Fixed IP Address"))], ('fixed_ip', _("Fixed IP Address"))],
widget=forms.Select(attrs={ widget=forms.ThemableSelectWidget(attrs={
'class': 'switchable', 'class': 'switchable',
'data-slug': 'specify_ip', 'data-slug': 'specify_ip',
})) }))
subnet_id = forms.ThemableChoiceField( subnet_id = forms.ThemableChoiceField(
label=_("Subnet"), label=_("Subnet"),
required=False, required=False,
widget=forms.Select(attrs={ widget=forms.ThemableSelectWidget(attrs={
'class': 'switched', 'class': 'switched',
'data-switch-on': 'specify_ip', 'data-switch-on': 'specify_ip',
'data-specify_ip-subnet_id': _('Subnet'), 'data-specify_ip-subnet_id': _('Subnet'),

@ -121,14 +121,14 @@ class CreateSubnetInfoAction(workflows.Action):
label=_('Network Address Source'), label=_('Network Address Source'),
choices=[('manual', _('Enter Network Address manually')), choices=[('manual', _('Enter Network Address manually')),
('subnetpool', _('Allocate Network Address from a pool'))], ('subnetpool', _('Allocate Network Address from a pool'))],
widget=forms.Select(attrs={ widget=forms.ThemableSelectWidget(attrs={
'class': 'switchable', 'class': 'switchable',
'data-slug': 'source', 'data-slug': 'source',
})) }))
subnetpool = forms.ChoiceField( subnetpool = forms.ChoiceField(
label=_("Address pool"), label=_("Address pool"),
widget=forms.SelectWidget(attrs={ widget=forms.ThemableSelectWidget(attrs={
'class': 'switched switchable', 'class': 'switched switchable',
'data-slug': 'subnetpool', 'data-slug': 'subnetpool',
'data-switch-on': 'source', 'data-switch-on': 'source',
@ -142,7 +142,7 @@ class CreateSubnetInfoAction(workflows.Action):
if 'prefixes' in x else "%s" % (x.name)), if 'prefixes' in x else "%s" % (x.name)),
required=False) required=False)
prefixlen = forms.ChoiceField(widget=forms.Select(attrs={ prefixlen = forms.ChoiceField(widget=forms.ThemableSelectWidget(attrs={
'class': 'switched', 'class': 'switched',
'data-switch-on': 'subnetpool', 'data-switch-on': 'subnetpool',
}), }),
@ -162,7 +162,7 @@ class CreateSubnetInfoAction(workflows.Action):
version=forms.IPv4 | forms.IPv6, version=forms.IPv4 | forms.IPv6,
mask=True) mask=True)
ip_version = forms.ChoiceField(choices=[(4, 'IPv4'), (6, 'IPv6')], ip_version = forms.ChoiceField(choices=[(4, 'IPv4'), (6, 'IPv6')],
widget=forms.Select(attrs={ widget=forms.ThemableSelectWidget(attrs={
'class': 'switchable', 'class': 'switchable',
'data-slug': 'ipversion', 'data-slug': 'ipversion',
}), }),
@ -348,7 +348,7 @@ class CreateSubnetDetailAction(workflows.Action):
initial=True, required=False) initial=True, required=False)
ipv6_modes = forms.ChoiceField( ipv6_modes = forms.ChoiceField(
label=_("IPv6 Address Configuration Mode"), label=_("IPv6 Address Configuration Mode"),
widget=forms.Select(attrs={ widget=forms.ThemableSelectWidget(attrs={
'class': 'switched', 'class': 'switched',
'data-switch-on': 'ipversion', 'data-switch-on': 'ipversion',
'data-ipversion-6': _("IPv6 Address Configuration Mode"), 'data-ipversion-6': _("IPv6 Address Configuration Mode"),

@ -104,7 +104,7 @@ class UpdateGroup(GroupBase):
class AddRule(forms.SelfHandlingForm): class AddRule(forms.SelfHandlingForm):
id = forms.CharField(widget=forms.HiddenInput()) id = forms.CharField(widget=forms.HiddenInput())
rule_menu = forms.ChoiceField(label=_('Rule'), rule_menu = forms.ChoiceField(label=_('Rule'),
widget=forms.Select(attrs={ widget=forms.ThemableSelectWidget(attrs={
'class': 'switchable', 'class': 'switchable',
'data-slug': 'rule_menu'})) 'data-slug': 'rule_menu'}))
@ -114,7 +114,7 @@ class AddRule(forms.SelfHandlingForm):
direction = forms.ChoiceField( direction = forms.ChoiceField(
label=_('Direction'), label=_('Direction'),
required=False, required=False,
widget=forms.Select(attrs={ widget=forms.ThemableSelectWidget(attrs={
'class': 'switched', 'class': 'switched',
'data-switch-on': 'rule_menu', 'data-switch-on': 'rule_menu',
'data-rule_menu-tcp': _('Direction'), 'data-rule_menu-tcp': _('Direction'),
@ -139,7 +139,7 @@ class AddRule(forms.SelfHandlingForm):
label=_('Open Port'), label=_('Open Port'),
choices=[('port', _('Port')), choices=[('port', _('Port')),
('range', _('Port Range'))], ('range', _('Port Range'))],
widget=forms.Select(attrs={ widget=forms.ThemableSelectWidget(attrs={
'class': 'switchable switched', 'class': 'switchable switched',
'data-slug': 'range', 'data-slug': 'range',
'data-switch-on': 'rule_menu', 'data-switch-on': 'rule_menu',
@ -210,7 +210,7 @@ class AddRule(forms.SelfHandlingForm):
'members of another security ' 'members of another security '
'group select "Security ' 'group select "Security '
'Group".'), 'Group".'),
widget=forms.Select(attrs={ widget=forms.ThemableSelectWidget(attrs={
'class': 'switchable', 'class': 'switchable',
'data-slug': 'remote'})) 'data-slug': 'remote'}))
@ -229,7 +229,8 @@ class AddRule(forms.SelfHandlingForm):
security_group = forms.ChoiceField(label=_('Security Group'), security_group = forms.ChoiceField(label=_('Security Group'),
required=False, required=False,
widget=forms.Select(attrs={ widget=forms.ThemableSelectWidget(
attrs={
'class': 'switched', 'class': 'switched',
'data-switch-on': 'remote', 'data-switch-on': 'remote',
'data-remote-sg': _('Security ' 'data-remote-sg': _('Security '
@ -240,7 +241,7 @@ class AddRule(forms.SelfHandlingForm):
required=False, required=False,
choices=[('IPv4', _('IPv4')), choices=[('IPv4', _('IPv4')),
('IPv6', _('IPv6'))], ('IPv6', _('IPv6'))],
widget=forms.Select(attrs={ widget=forms.ThemableSelectWidget(attrs={
'class': 'switched', 'class': 'switched',
'data-slug': 'ethertype', 'data-slug': 'ethertype',
'data-switch-on': 'remote', 'data-switch-on': 'remote',

@ -67,7 +67,8 @@ class TemplateForm(forms.SelfHandlingForm):
attributes = {'class': 'switchable', 'data-slug': 'templatesource'} attributes = {'class': 'switchable', 'data-slug': 'templatesource'}
template_source = forms.ChoiceField(label=_('Template Source'), template_source = forms.ChoiceField(label=_('Template Source'),
choices=base_choices + url_choice, choices=base_choices + url_choice,
widget=forms.Select(attrs=attributes)) widget=forms.ThemableSelectWidget(
attrs=attributes))
attributes = create_upload_form_attributes( attributes = create_upload_form_attributes(
'template', 'template',
@ -103,7 +104,7 @@ class TemplateForm(forms.SelfHandlingForm):
environment_source = forms.ChoiceField( environment_source = forms.ChoiceField(
label=_('Environment Source'), label=_('Environment Source'),
choices=base_choices, choices=base_choices,
widget=forms.Select(attrs=attributes), widget=forms.ThemableSelectWidget(attrs=attributes),
required=False) required=False)
attributes = create_upload_form_attributes( attributes = create_upload_form_attributes(

@ -73,7 +73,7 @@ class UpdateIKEPolicy(forms.SelfHandlingForm):
auth_algorithm = forms.ChoiceField( auth_algorithm = forms.ChoiceField(
label=_("Authorization algorithm"), label=_("Authorization algorithm"),
choices=[('sha1', _('sha1'))], choices=[('sha1', _('sha1'))],
widget=forms.Select(attrs={'readonly': 'readonly'}), widget=forms.ThemableSelectWidget(attrs={'readonly': 'readonly'}),
required=False) required=False)
encryption_algorithm = forms.ChoiceField( encryption_algorithm = forms.ChoiceField(
label=_("Encryption algorithm"), label=_("Encryption algorithm"),
@ -91,7 +91,7 @@ class UpdateIKEPolicy(forms.SelfHandlingForm):
lifetime_units = forms.ChoiceField( lifetime_units = forms.ChoiceField(
label=_("Lifetime units for IKE keys"), label=_("Lifetime units for IKE keys"),
choices=[('seconds', _('seconds'))], choices=[('seconds', _('seconds'))],
widget=forms.Select(attrs={'readonly': 'readonly'}), widget=forms.ThemableSelectWidget(attrs={'readonly': 'readonly'}),
required=False) required=False)
lifetime_value = forms.IntegerField( lifetime_value = forms.IntegerField(
min_value=60, min_value=60,
@ -108,7 +108,7 @@ class UpdateIKEPolicy(forms.SelfHandlingForm):
phase1_negotiation_mode = forms.ChoiceField( phase1_negotiation_mode = forms.ChoiceField(
label=_("IKE Phase1 negotiation mode"), label=_("IKE Phase1 negotiation mode"),
choices=[('main', 'main')], choices=[('main', 'main')],
widget=forms.Select(attrs={'readonly': 'readonly'}), widget=forms.ThemableSelectWidget(attrs={'readonly': 'readonly'}),
required=False) required=False)
failure_url = 'horizon:project:vpn:index' failure_url = 'horizon:project:vpn:index'
@ -170,7 +170,7 @@ class UpdateIPSecPolicy(forms.SelfHandlingForm):
lifetime_units = forms.ChoiceField( lifetime_units = forms.ChoiceField(
label=_("Lifetime units"), label=_("Lifetime units"),
choices=[('seconds', _('seconds'))], choices=[('seconds', _('seconds'))],
widget=forms.Select(attrs={'readonly': 'readonly'}), widget=forms.ThemableSelectWidget(attrs={'readonly': 'readonly'}),
required=False) required=False)
lifetime_value = forms.IntegerField( lifetime_value = forms.IntegerField(
min_value=60, min_value=60,