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

View File

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

View File

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

View File

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

View File

@ -91,10 +91,9 @@ DeploymentHistoryLogs = "div#environment_details__env_logs div.reports.logs "\
"div.report-info" "div.report-info"
PackageFilterDropdownBtn = 'div.table_search > div.themable-select.dropdown >'\ PackageFilterDropdownBtn = 'div.table_search > div.themable-select.dropdown >'\
' button' ' button'
PackageFilterTypeBtn = "a[data-select-value='{0}']"
PackageFilterInput = 'input[name="packages__filter_packages__q"]' PackageFilterInput = 'input[name="packages__filter_packages__q"]'
PackageFilterBtn = "packages__action_filter_packages" PackageFilterBtn = "packages__action_filter_packages"
ThemableSelect = 'label[for$="{0}"] ~ div div button.dropdown-toggle'
ThemableOption = "a[data-select-value='{0}']"
# Panels # Panels
AppCatalog = "//*[@id='main_content']/nav//a[contains(text(), 'App Catalog')]" # noqa 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( self.wait_element_is_clickable(
by.By.CSS_SELECTOR, c.PackageFilterDropdownBtn).click() by.By.CSS_SELECTOR, c.PackageFilterDropdownBtn).click()
self.wait_element_is_clickable( 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: for package_name in packages_by_name:
self.fill_field(by.By.CSS_SELECTOR, c.PackageFilterInput, self.fill_field(by.By.CSS_SELECTOR, c.PackageFilterInput,
@ -2476,7 +2476,7 @@ class TestSuitePackages(base.PackageTestCase):
self.wait_element_is_clickable( self.wait_element_is_clickable(
by.By.CSS_SELECTOR, c.PackageFilterDropdownBtn).click() by.By.CSS_SELECTOR, c.PackageFilterDropdownBtn).click()
self.wait_element_is_clickable( 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(): for package_type, package_list in packages_by_type.items():
self.fill_field(by.By.CSS_SELECTOR, c.PackageFilterInput, self.fill_field(by.By.CSS_SELECTOR, c.PackageFilterInput,
@ -2532,7 +2532,7 @@ class TestSuitePackages(base.PackageTestCase):
self.wait_element_is_clickable( self.wait_element_is_clickable(
by.By.CSS_SELECTOR, c.PackageFilterDropdownBtn).click() by.By.CSS_SELECTOR, c.PackageFilterDropdownBtn).click()
self.wait_element_is_clickable( self.wait_element_is_clickable(
by.By.CSS_SELECTOR, c.ThemableOption.format('search'))\ by.By.CSS_SELECTOR, c.PackageFilterTypeBtn.format('search'))\
.click() .click()
for keyword, package_name in packages_by_keyword.items(): for keyword, package_name in packages_by_keyword.items():
@ -2834,7 +2834,10 @@ class TestSuiteRepository(base.PackageTestCase):
self.navigate_to('Manage') self.navigate_to('Manage')
self.go_to_submenu('Packages') self.go_to_submenu('Packages')
self.driver.find_element_by_id(c.UploadPackage).click() 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( el = self.driver.find_element_by_css_selector(
"input[name='upload-url']") "input[name='upload-url']")
@ -2864,7 +2867,10 @@ class TestSuiteRepository(base.PackageTestCase):
self.navigate_to('Manage') self.navigate_to('Manage')
self.go_to_submenu('Packages') self.go_to_submenu('Packages')
self.driver.find_element_by_id(c.UploadPackage).click() 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( el = self.driver.find_element_by_css_selector(
"input[name='upload-repo_name']") "input[name='upload-repo_name']")
@ -2901,8 +2907,10 @@ class TestSuiteRepository(base.PackageTestCase):
self.navigate_to('Manage') self.navigate_to('Manage')
self.go_to_submenu('Packages') self.go_to_submenu('Packages')
self.driver.find_element_by_id(c.ImportBundle).click() self.driver.find_element_by_id(c.ImportBundle).click()
sel = self.driver.find_element_by_css_selector(
self.select_from_list('import_type', 'by_url') "select[name='upload-import_type']")
sel = ui.Select(sel)
sel.select_by_value("by_url")
el = self.driver.find_element_by_css_selector( el = self.driver.find_element_by_css_selector(
"input[name='upload-url']") "input[name='upload-url']")
@ -2937,8 +2945,10 @@ class TestSuiteRepository(base.PackageTestCase):
self.navigate_to('Manage') self.navigate_to('Manage')
self.go_to_submenu('Packages') self.go_to_submenu('Packages')
self.driver.find_element_by_id(c.ImportBundle).click() self.driver.find_element_by_id(c.ImportBundle).click()
sel = self.driver.find_element_by_css_selector(
self.select_from_list('import_type', 'by_name') "select[name='upload-import_type']")
sel = ui.Select(sel)
sel.select_by_value("by_name")
el = self.driver.find_element_by_css_selector( el = self.driver.find_element_by_css_selector(
"input[name='upload-name']") "input[name='upload-name']")
@ -2971,8 +2981,10 @@ class TestSuiteRepository(base.PackageTestCase):
self.navigate_to('Manage') self.navigate_to('Manage')
self.go_to_submenu('Packages') self.go_to_submenu('Packages')
self.driver.find_element_by_id(c.UploadPackage).click() self.driver.find_element_by_id(c.UploadPackage).click()
sel = self.driver.find_element_by_css_selector(
self.select_from_list('import_type', 'by_name') "select[name='upload-import_type']")
sel = ui.Select(sel)
sel.select_by_value("by_name")
el = self.driver.find_element_by_css_selector( el = self.driver.find_element_by_css_selector(
"input[name='upload-repo_name']") "input[name='upload-repo_name']")
@ -2999,7 +3011,10 @@ class TestSuiteRepository(base.PackageTestCase):
# Invalid folder # Invalid folder
self.driver.find_element_by_id(c.UploadPackage).click() 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( el = self.driver.find_element_by_css_selector(
"input[name='upload-url']") "input[name='upload-url']")
el.send_keys("http://127.0.0.1:8099/None/{0}.zip".format(pkg_name)) 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 # HTTP connect error
self.driver.find_element_by_id(c.UploadPackage).click() 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( el = self.driver.find_element_by_css_selector(
"input[name='upload-url']") "input[name='upload-url']")
el.send_keys("http://127.0.0.2:12345/apps/{0}.zip".format(pkg_name)) 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 # Invalid app name
self.driver.find_element_by_id(c.UploadPackage).click() 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( el = self.driver.find_element_by_css_selector(
"input[name='upload-url']") "input[name='upload-url']")
el.send_keys( el.send_keys(
@ -3037,7 +3058,10 @@ class TestSuiteRepository(base.PackageTestCase):
self.navigate_to('Manage') self.navigate_to('Manage')
self.go_to_submenu('Packages') self.go_to_submenu('Packages')
self.driver.find_element_by_id(c.UploadPackage).click() 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( el = self.driver.find_element_by_css_selector(
"input[name='upload-repo_name']") "input[name='upload-repo_name']")
@ -3058,7 +3082,10 @@ class TestSuiteRepository(base.PackageTestCase):
self.navigate_to('Manage') self.navigate_to('Manage')
self.go_to_submenu('Packages') self.go_to_submenu('Packages')
self.driver.find_element_by_id(c.UploadPackage).click() 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( el = self.driver.find_element_by_css_selector(
"input[name='upload-repo_name']") "input[name='upload-repo_name']")
@ -3082,7 +3109,10 @@ class TestSuiteRepository(base.PackageTestCase):
self.navigate_to('Manage') self.navigate_to('Manage')
self.go_to_submenu('Packages') self.go_to_submenu('Packages')
self.driver.find_element_by_id(c.UploadPackage).click() 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( el = self.driver.find_element_by_css_selector(
"input[name='upload-repo_name']") "input[name='upload-repo_name']")
@ -3116,8 +3146,10 @@ class TestSuiteRepository(base.PackageTestCase):
self.navigate_to('Manage') self.navigate_to('Manage')
self.go_to_submenu('Packages') self.go_to_submenu('Packages')
self.driver.find_element_by_id(c.UploadPackage).click() self.driver.find_element_by_id(c.UploadPackage).click()
sel = self.driver.find_element_by_css_selector(
self.select_from_list('import_type', 'by_name') "select[name='upload-import_type']")
sel = ui.Select(sel)
sel.select_by_value("by_name")
el = self.driver.find_element_by_css_selector( el = self.driver.find_element_by_css_selector(
"input[name='upload-repo_name']") "input[name='upload-repo_name']")
@ -3153,7 +3185,10 @@ class TestSuiteRepository(base.PackageTestCase):
self.navigate_to('Manage') self.navigate_to('Manage')
self.go_to_submenu('Packages') self.go_to_submenu('Packages')
self.driver.find_element_by_id(c.UploadPackage).click() 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( el = self.driver.find_element_by_css_selector(
"input[name='upload-repo_name']") "input[name='upload-repo_name']")
@ -3202,7 +3237,10 @@ class TestSuiteRepository(base.PackageTestCase):
self.navigate_to('Manage') self.navigate_to('Manage')
self.go_to_submenu('Packages') self.go_to_submenu('Packages')
self.driver.find_element_by_id(c.ImportBundle).click() 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( el = self.driver.find_element_by_css_selector(
"input[name='upload-name']") "input[name='upload-name']")