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:
Vadym Markov 2023-02-26 22:53:29 +02:00 committed by BubaVV
parent 315d2885b3
commit 8ffea4c82e
2 changed files with 4 additions and 7 deletions

View File

@ -127,8 +127,8 @@ class CreateShareGroupForm(forms.SelfHandlingForm):
}),
required=True)
self.fields["sgt"].choices = (
[("", "")] + [(utils.transform_dashed_name(sgt.id), sgt.name)
for sgt in share_group_types]
[(utils.transform_dashed_name(sgt.id), sgt.name) for sgt in
share_group_types]
)
# NOTE(vponomaryov): create separate set of available share types
@ -180,7 +180,6 @@ class CreateShareGroupForm(forms.SelfHandlingForm):
required=False)
share_networks = manila.share_network_list(request)
self.fields["share_network"].choices = (
[("", "")] +
[(sn.id, sn.name or sn.id) for sn in share_networks])
def clean(self):

View File

@ -58,9 +58,8 @@ class CreateForm(forms.SelfHandlingForm):
share_networks = manila.share_network_list(request)
share_types = manila.share_type_list(request)
self.fields['share_type'].choices = (
[("", "")] +
[(utils.transform_dashed_name(st.name), st.name)
for st in share_types]
[(utils.transform_dashed_name(st.name), st.name) for st in
share_types]
)
availability_zones = manila.availability_zone_list(request)
@ -83,7 +82,6 @@ class CreateForm(forms.SelfHandlingForm):
# share types with enabled handling of share servers.
if (isinstance(dhss, str) and dhss.lower() in ['true', '1']):
sn_choices = (
[('', '')] +
[(sn.id, sn.name or sn.id) for sn in share_networks])
sn_field_name = (
self.sn_field_name_prefix +