Remove empty choices added to required fields
Almost all selectors in dashboard forms add empty string as option. It is ok for non-required fields, but invalid for required fields like "Share Group type" at "Share Group create" form. Proposed patch removes this empty string where it is invalid Change-Id: I0eef44eec858dfbf287930a7d318fb1570450e3c
This commit is contained in:
@@ -127,8 +127,8 @@ class CreateShareGroupForm(forms.SelfHandlingForm):
|
|||||||
}),
|
}),
|
||||||
required=True)
|
required=True)
|
||||||
self.fields["sgt"].choices = (
|
self.fields["sgt"].choices = (
|
||||||
[("", "")] + [(utils.transform_dashed_name(sgt.id), sgt.name)
|
[(utils.transform_dashed_name(sgt.id), sgt.name) for sgt in
|
||||||
for sgt in share_group_types]
|
share_group_types]
|
||||||
)
|
)
|
||||||
|
|
||||||
# NOTE(vponomaryov): create separate set of available share types
|
# NOTE(vponomaryov): create separate set of available share types
|
||||||
@@ -180,7 +180,6 @@ class CreateShareGroupForm(forms.SelfHandlingForm):
|
|||||||
required=False)
|
required=False)
|
||||||
share_networks = manila.share_network_list(request)
|
share_networks = manila.share_network_list(request)
|
||||||
self.fields["share_network"].choices = (
|
self.fields["share_network"].choices = (
|
||||||
[("", "")] +
|
|
||||||
[(sn.id, sn.name or sn.id) for sn in share_networks])
|
[(sn.id, sn.name or sn.id) for sn in share_networks])
|
||||||
|
|
||||||
def clean(self):
|
def clean(self):
|
||||||
|
|||||||
@@ -58,9 +58,8 @@ class CreateForm(forms.SelfHandlingForm):
|
|||||||
share_networks = manila.share_network_list(request)
|
share_networks = manila.share_network_list(request)
|
||||||
share_types = manila.share_type_list(request)
|
share_types = manila.share_type_list(request)
|
||||||
self.fields['share_type'].choices = (
|
self.fields['share_type'].choices = (
|
||||||
[("", "")] +
|
[(utils.transform_dashed_name(st.name), st.name) for st in
|
||||||
[(utils.transform_dashed_name(st.name), st.name)
|
share_types]
|
||||||
for st in share_types]
|
|
||||||
)
|
)
|
||||||
|
|
||||||
availability_zones = manila.availability_zone_list(request)
|
availability_zones = manila.availability_zone_list(request)
|
||||||
@@ -83,7 +82,6 @@ class CreateForm(forms.SelfHandlingForm):
|
|||||||
# share types with enabled handling of share servers.
|
# share types with enabled handling of share servers.
|
||||||
if (isinstance(dhss, str) and dhss.lower() in ['true', '1']):
|
if (isinstance(dhss, str) and dhss.lower() in ['true', '1']):
|
||||||
sn_choices = (
|
sn_choices = (
|
||||||
[('', '')] +
|
|
||||||
[(sn.id, sn.name or sn.id) for sn in share_networks])
|
[(sn.id, sn.name or sn.id) for sn in share_networks])
|
||||||
sn_field_name = (
|
sn_field_name = (
|
||||||
self.sn_field_name_prefix +
|
self.sn_field_name_prefix +
|
||||||
|
|||||||
Reference in New Issue
Block a user