Revert ThemableSelectWidget for themable selects

Now horizon ThemableSelectWidget field can not display
the validation error, just make the field keep the old
can temporary fix this. Once horizon fixed,
we can revert it back.

This reverts commit 85fc5e002c.
Closes-Bug: #1711763

Change-Id: I557d38f739786597a9472c8104e1edf531e9a007
This commit is contained in:
zhurong 2017-08-25 10:09:30 +08:00
parent baf32df269
commit d76bbb9949
6 changed files with 73 additions and 45 deletions

View File

@ -348,12 +348,10 @@ class ChoiceField(forms.ChoiceField, CustomPropertiesField):
if isinstance(choices, dict):
choices = list(choices.items())
kwargs['choices'] = choices
kwargs['widget'] = hz_forms.ThemableSelectWidget(transform=_get_title)
super(ChoiceField, self).__init__(**kwargs)
class DynamicChoiceField(hz_forms.ThemableDynamicChoiceField,
CustomPropertiesField):
class DynamicChoiceField(hz_forms.DynamicChoiceField, CustomPropertiesField):
pass
@ -444,9 +442,8 @@ class Choice(object):
class ImageChoiceField(ChoiceField):
widget = hz_forms.ThemableSelectWidget(
transform=_get_title,
transform_html_attrs=_disable_non_ready)
widget = hz_forms.SelectWidget(transform=_get_title,
transform_html_attrs=_disable_non_ready)
def __init__(self, *args, **kwargs):
self.image_type = kwargs.pop('image_type', None)

View File

@ -59,15 +59,13 @@ class MarkImageForm(horizon_forms.SelfHandlingForm):
'custom': "Custom type"
}
image = forms.ChoiceField(
label=_('Image'),
widget=horizon_forms.ThemableSelectWidget())
image = forms.ChoiceField(label=_('Image'))
title = forms.CharField(max_length="255", label=_("Title"))
type = forms.ChoiceField(
label=_("Type"),
choices=_metadata.items(),
initial='custom',
widget=horizon_forms.ThemableSelectWidget(attrs={
widget=forms.Select(attrs={
'class': 'switchable',
'data-slug': 'type'}))
custom_type = forms.CharField(

View File

@ -52,7 +52,7 @@ class ImportBundleForm(forms.Form):
import_type = forms.ChoiceField(
label=_("Package Bundle Source"),
choices=IMPORT_BUNDLE_TYPE_CHOICES,
widget=horizon_forms.ThemableSelectWidget(attrs={
widget=forms.Select(attrs={
'class': 'switchable',
'data-slug': 'source'}))
url = PackageURLField(
@ -88,7 +88,7 @@ class ImportPackageForm(forms.Form):
import_type = forms.ChoiceField(
label=_("Package Source"),
choices=IMPORT_TYPE_CHOICES,
widget=horizon_forms.ThemableSelectWidget(attrs={
widget=forms.Select(attrs={
'class': 'switchable',
'data-slug': 'source'}))
url = PackageURLField(

View File

@ -256,16 +256,12 @@ class UITestCase(testtools.TestCase):
el.click()
def select_from_list(self, list_name, value, sec=10):
self.check_element_on_page(by.By.CSS_SELECTOR,
consts.ThemableSelect.format(list_name))
self.wait_element_is_clickable(
by.By.CSS_SELECTOR, consts.ThemableSelect.format(
list_name)).click()
self.check_element_on_page(by.By.CSS_SELECTOR,
consts.ThemableOption.format(value))
self.wait_element_is_clickable(
by.By.CSS_SELECTOR,
consts.ThemableOption.format(value)).click()
locator = (by.By.XPATH,
"//select[contains(@name, '{0}')]"
"/option[@value='{1}']".format(list_name, value))
el = ui.WebDriverWait(self.driver, sec).until(
EC.presence_of_element_located(locator))
el.click()
def check_element_on_page(self, method, value, sec=10):
try:

View File

@ -91,10 +91,9 @@ DeploymentHistoryLogs = "div#environment_details__env_logs div.reports.logs "\
"div.report-info"
PackageFilterDropdownBtn = 'div.table_search > div.themable-select.dropdown >'\
' button'
PackageFilterTypeBtn = "a[data-select-value='{0}']"
PackageFilterInput = 'input[name="packages__filter_packages__q"]'
PackageFilterBtn = "packages__action_filter_packages"
ThemableSelect = 'label[for$="{0}"] ~ div div button.dropdown-toggle'
ThemableOption = "a[data-select-value='{0}']"
# Panels
AppCatalog = "//*[@id='main_content']/nav//a[contains(text(), 'App Catalog')]" # noqa

View File

@ -2436,7 +2436,7 @@ class TestSuitePackages(base.PackageTestCase):
self.wait_element_is_clickable(
by.By.CSS_SELECTOR, c.PackageFilterDropdownBtn).click()
self.wait_element_is_clickable(
by.By.CSS_SELECTOR, c.ThemableOption.format('name')).click()
by.By.CSS_SELECTOR, c.PackageFilterTypeBtn.format('name')).click()
for package_name in packages_by_name:
self.fill_field(by.By.CSS_SELECTOR, c.PackageFilterInput,
@ -2476,7 +2476,7 @@ class TestSuitePackages(base.PackageTestCase):
self.wait_element_is_clickable(
by.By.CSS_SELECTOR, c.PackageFilterDropdownBtn).click()
self.wait_element_is_clickable(
by.By.CSS_SELECTOR, c.ThemableOption.format('type')).click()
by.By.CSS_SELECTOR, c.PackageFilterTypeBtn.format('type')).click()
for package_type, package_list in packages_by_type.items():
self.fill_field(by.By.CSS_SELECTOR, c.PackageFilterInput,
@ -2532,7 +2532,7 @@ class TestSuitePackages(base.PackageTestCase):
self.wait_element_is_clickable(
by.By.CSS_SELECTOR, c.PackageFilterDropdownBtn).click()
self.wait_element_is_clickable(
by.By.CSS_SELECTOR, c.ThemableOption.format('search'))\
by.By.CSS_SELECTOR, c.PackageFilterTypeBtn.format('search'))\
.click()
for keyword, package_name in packages_by_keyword.items():
@ -2834,7 +2834,10 @@ class TestSuiteRepository(base.PackageTestCase):
self.navigate_to('Manage')
self.go_to_submenu('Packages')
self.driver.find_element_by_id(c.UploadPackage).click()
self.select_from_list('import_type', 'by_url')
sel = self.driver.find_element_by_css_selector(
"select[name='upload-import_type']")
sel = ui.Select(sel)
sel.select_by_value("by_url")
el = self.driver.find_element_by_css_selector(
"input[name='upload-url']")
@ -2864,7 +2867,10 @@ class TestSuiteRepository(base.PackageTestCase):
self.navigate_to('Manage')
self.go_to_submenu('Packages')
self.driver.find_element_by_id(c.UploadPackage).click()
self.select_from_list('import_type', 'by_name')
sel = self.driver.find_element_by_css_selector(
"select[name='upload-import_type']")
sel = ui.Select(sel)
sel.select_by_value("by_name")
el = self.driver.find_element_by_css_selector(
"input[name='upload-repo_name']")
@ -2901,8 +2907,10 @@ class TestSuiteRepository(base.PackageTestCase):
self.navigate_to('Manage')
self.go_to_submenu('Packages')
self.driver.find_element_by_id(c.ImportBundle).click()
self.select_from_list('import_type', 'by_url')
sel = self.driver.find_element_by_css_selector(
"select[name='upload-import_type']")
sel = ui.Select(sel)
sel.select_by_value("by_url")
el = self.driver.find_element_by_css_selector(
"input[name='upload-url']")
@ -2937,8 +2945,10 @@ class TestSuiteRepository(base.PackageTestCase):
self.navigate_to('Manage')
self.go_to_submenu('Packages')
self.driver.find_element_by_id(c.ImportBundle).click()
self.select_from_list('import_type', 'by_name')
sel = self.driver.find_element_by_css_selector(
"select[name='upload-import_type']")
sel = ui.Select(sel)
sel.select_by_value("by_name")
el = self.driver.find_element_by_css_selector(
"input[name='upload-name']")
@ -2971,8 +2981,10 @@ class TestSuiteRepository(base.PackageTestCase):
self.navigate_to('Manage')
self.go_to_submenu('Packages')
self.driver.find_element_by_id(c.UploadPackage).click()
self.select_from_list('import_type', 'by_name')
sel = self.driver.find_element_by_css_selector(
"select[name='upload-import_type']")
sel = ui.Select(sel)
sel.select_by_value("by_name")
el = self.driver.find_element_by_css_selector(
"input[name='upload-repo_name']")
@ -2999,7 +3011,10 @@ class TestSuiteRepository(base.PackageTestCase):
# Invalid folder
self.driver.find_element_by_id(c.UploadPackage).click()
self.select_from_list('import_type', 'by_url')
sel = self.driver.find_element_by_css_selector(
"select[name='upload-import_type']")
sel = ui.Select(sel)
sel.select_by_value("by_url")
el = self.driver.find_element_by_css_selector(
"input[name='upload-url']")
el.send_keys("http://127.0.0.1:8099/None/{0}.zip".format(pkg_name))
@ -3008,7 +3023,10 @@ class TestSuiteRepository(base.PackageTestCase):
# HTTP connect error
self.driver.find_element_by_id(c.UploadPackage).click()
self.select_from_list('import_type', 'by_url')
sel = self.driver.find_element_by_css_selector(
"select[name='upload-import_type']")
sel = ui.Select(sel)
sel.select_by_value("by_url")
el = self.driver.find_element_by_css_selector(
"input[name='upload-url']")
el.send_keys("http://127.0.0.2:12345/apps/{0}.zip".format(pkg_name))
@ -3017,7 +3035,10 @@ class TestSuiteRepository(base.PackageTestCase):
# Invalid app name
self.driver.find_element_by_id(c.UploadPackage).click()
self.select_from_list('import_type', 'by_url')
sel = self.driver.find_element_by_css_selector(
"select[name='upload-import_type']")
sel = ui.Select(sel)
sel.select_by_value("by_url")
el = self.driver.find_element_by_css_selector(
"input[name='upload-url']")
el.send_keys(
@ -3037,7 +3058,10 @@ class TestSuiteRepository(base.PackageTestCase):
self.navigate_to('Manage')
self.go_to_submenu('Packages')
self.driver.find_element_by_id(c.UploadPackage).click()
self.select_from_list('import_type', 'by_name')
sel = self.driver.find_element_by_css_selector(
"select[name='upload-import_type']")
sel = ui.Select(sel)
sel.select_by_value("by_name")
el = self.driver.find_element_by_css_selector(
"input[name='upload-repo_name']")
@ -3058,7 +3082,10 @@ class TestSuiteRepository(base.PackageTestCase):
self.navigate_to('Manage')
self.go_to_submenu('Packages')
self.driver.find_element_by_id(c.UploadPackage).click()
self.select_from_list('import_type', 'by_name')
sel = self.driver.find_element_by_css_selector(
"select[name='upload-import_type']")
sel = ui.Select(sel)
sel.select_by_value("by_name")
el = self.driver.find_element_by_css_selector(
"input[name='upload-repo_name']")
@ -3082,7 +3109,10 @@ class TestSuiteRepository(base.PackageTestCase):
self.navigate_to('Manage')
self.go_to_submenu('Packages')
self.driver.find_element_by_id(c.UploadPackage).click()
self.select_from_list('import_type', 'by_name')
sel = self.driver.find_element_by_css_selector(
"select[name='upload-import_type']")
sel = ui.Select(sel)
sel.select_by_value("by_name")
el = self.driver.find_element_by_css_selector(
"input[name='upload-repo_name']")
@ -3116,8 +3146,10 @@ class TestSuiteRepository(base.PackageTestCase):
self.navigate_to('Manage')
self.go_to_submenu('Packages')
self.driver.find_element_by_id(c.UploadPackage).click()
self.select_from_list('import_type', 'by_name')
sel = self.driver.find_element_by_css_selector(
"select[name='upload-import_type']")
sel = ui.Select(sel)
sel.select_by_value("by_name")
el = self.driver.find_element_by_css_selector(
"input[name='upload-repo_name']")
@ -3153,7 +3185,10 @@ class TestSuiteRepository(base.PackageTestCase):
self.navigate_to('Manage')
self.go_to_submenu('Packages')
self.driver.find_element_by_id(c.UploadPackage).click()
self.select_from_list('import_type', 'by_name')
sel = self.driver.find_element_by_css_selector(
"select[name='upload-import_type']")
sel = ui.Select(sel)
sel.select_by_value("by_name")
el = self.driver.find_element_by_css_selector(
"input[name='upload-repo_name']")
@ -3202,7 +3237,10 @@ class TestSuiteRepository(base.PackageTestCase):
self.navigate_to('Manage')
self.go_to_submenu('Packages')
self.driver.find_element_by_id(c.ImportBundle).click()
self.select_from_list('import_type', 'by_name')
sel = self.driver.find_element_by_css_selector(
"select[name='upload-import_type']")
sel = ui.Select(sel)
sel.select_by_value("by_name")
el = self.driver.find_element_by_css_selector(
"input[name='upload-name']")