From e66fbc3b9f3cc0ab800c8d7caef8d8e61d5a9eb6 Mon Sep 17 00:00:00 2001 From: Ana Krivokapic Date: Tue, 10 Jun 2014 14:14:06 +0200 Subject: 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) --- .../dashboards/project/access_and_security/security_groups/views.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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) -- cgit v1.2.1