summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAna Krivokapic <akrivoka@redhat.com>2014-06-10 14:14:06 +0200
committerAna Krivokapic <akrivoka@redhat.com>2014-07-18 15:04:02 +0000
commite66fbc3b9f3cc0ab800c8d7caef8d8e61d5a9eb6 (patch)
treebc45c2c5a9182985b35620dca07ac94315ecf0ee
parenta855b0c972753d352bf3043a0d49e2411fb87ea1 (diff)
downloadhorizon-e66fbc3b9f3cc0ab800c8d7caef8d8e61d5a9eb6.tar.gz
Sort security group rules by protocol and port
When adding new rules to a security group, it is useful to have the rules sorted consistently across page reloads. This patch ensures that the rules are sorted by protocol first, then by port. It is still possible to manually sort the table using the client side capabilities, but by default the table is now sorted by protocol and port, server side. Change-Id: I36d29461a8437f5689425706a7faae3399c6bf23 Closes-bug: #1326132 (cherry picked from commit e8c1f60eae7e3a76fd271dd5f14c80d06dfe6ebd)
-rw-r--r--openstack_dashboard/dashboards/project/access_and_security/security_groups/views.py3
1 files changed, 2 insertions, 1 deletions
diff --git a/openstack_dashboard/dashboards/project/access_and_security/security_groups/views.py b/openstack_dashboard/dashboards/project/access_and_security/security_groups/views.py
index 5aefbf497..093f216e9 100644
--- a/openstack_dashboard/dashboards/project/access_and_security/security_groups/views.py
+++ b/openstack_dashboard/dashboards/project/access_and_security/security_groups/views.py
@@ -58,7 +58,8 @@ class DetailView(tables.DataTableView):
data = self._get_data()
if data is None:
return []
- return data.rules
+ return sorted(data.rules, key=lambda rule: (rule.ip_protocol,
+ rule.from_port))
def get_context_data(self, **kwargs):
context = super(DetailView, self).get_context_data(**kwargs)