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 e8c1f60eae)
This commit is contained in:
Ana Krivokapic 2014-06-10 14:14:06 +02:00
parent a855b0c972
commit e66fbc3b9f
1 changed files with 2 additions and 1 deletions

View File

@ -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)