Commit 96ad1bfa authored by Franco Fichtner's avatar Franco Fichtner

shaper: sort numerically, not alphabethically

(cherry picked from commit 98333c13)
(cherry picked from commit 56f7c3f8)
parent 3e77a688
...@@ -201,7 +201,7 @@ POSSIBILITY OF SUCH DAMAGE. ...@@ -201,7 +201,7 @@ POSSIBILITY OF SUCH DAMAGE.
</div> </div>
<div class="col-md-12"> <div class="col-md-12">
<hr/> <hr/>
<button class="btn btn-primary" id="reconfigureAct" type="button"><b>{{ lang._('Apply') }}</b><i id="reconfigureAct_progress" class=""></i></button> <button class="btn btn-primary" id="reconfigureAct" type="button"><b>{{ lang._('Apply') }}</b> <i id="reconfigureAct_progress" class=""></i></button>
<br/><br/> <br/><br/>
</div> </div>
</div> </div>
......
...@@ -28,7 +28,6 @@ ...@@ -28,7 +28,6 @@
package : configd package : configd
""" """
from operator import itemgetter
import netaddr import netaddr
...@@ -68,7 +67,7 @@ class Helpers(object): ...@@ -68,7 +67,7 @@ class Helpers(object):
else: else:
return False return False
def toList(self, tag, sortBy=None): def toList(self, tag, sortBy=None, sortAs=None):
""" if an item should be a list of items (repeating tag), use this method to make sure that we always return """ if an item should be a list of items (repeating tag), use this method to make sure that we always return
a list. The configuration doesn't know if a non repeating item is supposed to be a list of items, this makes a list. The configuration doesn't know if a non repeating item is supposed to be a list of items, this makes
it explicit. it explicit.
...@@ -85,7 +84,10 @@ class Helpers(object): ...@@ -85,7 +84,10 @@ class Helpers(object):
return result return result
else: else:
# resort list by tag # resort list by tag
return sorted(result, key=itemgetter(sortBy)) if sortAs is 'int':
return sorted(result, key=lambda d: int(d[sortBy]))
else:
return sorted(result, key=lambda d: d[sortBy])
def getUUIDtag(self, uuid): def getUUIDtag(self, uuid):
""" retrieve tag name of registered uuid, returns __not_found__ if none available """ retrieve tag name of registered uuid, returns __not_found__ if none available
......
...@@ -164,7 +164,7 @@ add 30000 set 0 count ip from any to any ...@@ -164,7 +164,7 @@ add 30000 set 0 count ip from any to any
add 60000 return via any add 60000 return via any
{% if helpers.exists('OPNsense.TrafficShaper.rules.rule') %} {% if helpers.exists('OPNsense.TrafficShaper.rules.rule') %}
{% for rule in helpers.toList('OPNsense.TrafficShaper.rules.rule', 'sequence') %} {% for rule in helpers.toList('OPNsense.TrafficShaper.rules.rule', 'sequence', 'int') %}
{% if helpers.getUUIDtag(rule.target) in ['pipe','queue'] %} {% if helpers.getUUIDtag(rule.target) in ['pipe','queue'] %}
{% if physical_interface(rule.interface) %} {% if physical_interface(rule.interface) %}
{% if helpers.getUUID(rule.target).enabled|default('0') == '1' %} {% if helpers.getUUID(rule.target).enabled|default('0') == '1' %}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment