summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDan Callaghan <dcallagh@redhat.com>2014-07-07 13:23:27 +1000
committerDan Callaghan <dcallagh@redhat.com>2014-07-07 13:23:27 +1000
commit8dec804f5d240b3a8a18179ec6a9bc0d002930a6 (patch)
tree520eaaa49428529b7f404e18da6c6f103e81fec0
parent97ab8f4c5f453870a06cf37f70c9e8ed9f68aca5 (diff)
fix system page activity grid sorting
The fix for bug 1097094 (commit 49e16e2f) broke the grid sorting because the .dyn_activity query has a default order_by clause applied, and @paginate does not clear the existing ordering before it applies its own. Bug: 1097094 Change-Id: I18744286cd71530067dcf8475d7e77a1e303cd88
-rw-r--r--IntegrationTests/src/bkr/inttest/server/selenium/test_system_view.py29
-rw-r--r--Server/bkr/server/controllers.py5
2 files changed, 31 insertions, 3 deletions
diff --git a/IntegrationTests/src/bkr/inttest/server/selenium/test_system_view.py b/IntegrationTests/src/bkr/inttest/server/selenium/test_system_view.py
index 99d9c75..0f317b1 100644
--- a/IntegrationTests/src/bkr/inttest/server/selenium/test_system_view.py
+++ b/IntegrationTests/src/bkr/inttest/server/selenium/test_system_view.py
@@ -23,7 +23,7 @@ from bkr.inttest.server.selenium import WebDriverTestCase
from bkr.inttest.server.webdriver_utils import login, check_system_search_results, \
delete_and_confirm, logout, click_menu_item
from selenium.webdriver.support.ui import Select
-from bkr.inttest.assertions import wait_for_condition
+from bkr.inttest.assertions import wait_for_condition, assert_sorted
class SystemViewTestWD(WebDriverTestCase):
@@ -735,6 +735,33 @@ class SystemViewTestWD(WebDriverTestCase):
'//input[@name="excluded_families_subsection.i386" and @value="%s"]'
% self.distro_tree.distro.osversion_id).is_selected())
+ def test_can_sort_activity_grid(self):
+ with session.begin():
+ self.system.record_activity(service=u'testdata', field=u'status_reason',
+ new=u'aaa')
+ self.system.record_activity(service=u'testdata', field=u'status_reason',
+ new=u'bbb')
+ self.system.record_activity(service=u'testdata', field=u'status_reason',
+ new=u'ccc')
+ b = self.browser
+ login(b)
+ self.go_to_system_view(self.system)
+ b.find_element_by_xpath('//ul[@class="nav nav-tabs"]//a[text()="History"]').click()
+ tab = b.find_element_by_id('history')
+ table = tab.find_element_by_xpath('.//table[@id="widget"]')
+ column = 7 # New Value
+ # by default the grid is sorted by id descending
+ cell_values = [table.find_element_by_xpath('tbody/tr[%d]/td[%d]'
+ % (row, column)).text for row in [1, 2, 3]]
+ self.assertEquals(cell_values, ['ccc', 'bbb', 'aaa'])
+ # sort by New Value column
+ table.find_element_by_xpath('thead/tr/th[%d]/a[text()="New Value"]' % column).click()
+ tab = b.find_element_by_id('history')
+ table = tab.find_element_by_xpath('.//table[@id="widget"]')
+ cell_values = [table.find_element_by_xpath('tbody/tr[%d]/td[%d]'
+ % (row, column)).text for row in [1, 2, 3]]
+ self.assertEquals(cell_values, ['aaa', 'bbb', 'ccc'])
+
class SystemCcTest(WebDriverTestCase):
def setUp(self):
diff --git a/Server/bkr/server/controllers.py b/Server/bkr/server/controllers.py
index b490ee9..d0101d3 100644
--- a/Server/bkr/server/controllers.py
+++ b/Server/bkr/server/controllers.py
@@ -814,7 +814,7 @@ class Root(RPCRoot):
@expose(template="bkr.server.templates.system")
- @paginate('history_data',limit=30,default_order='-created')
+ @paginate('history_data',limit=30,default_order='-id')
def _view_system_as_html(self, fqdn=None, **kw):
if fqdn:
try:
@@ -861,7 +861,8 @@ class Root(RPCRoot):
if 'activities_found' in histories_return:
historical_data = histories_return['activities_found']
else:
- historical_data = system.dyn_activity
+ # data grid will apply its own ordering
+ historical_data = system.dyn_activity.order_by(None)
if readonly:
attrs = dict(readonly = 'True')