Closed lbergesio closed 11 years ago
Fixed.
Range headers where showing From N...
and ranges started in N-1
.
This is due to the use of forloop.counter
( The current iteration of the loop (1-indexed)).
By using forloop.counter0
( The current iteration of the loop (0-indexed)) in the template code where the range headers are shown ( not where logic is computed) this minor issue is solved.
More information: Django tags and filters (for)
There were also another two problems..
Instead of 5 columns (the number thought in the beginning), 6 columns were being computed (sometimes this last column was empty). This happened because the VLAN range is: [0, 4095], which has a length of 4096.
Integer division of 4096/5
returns 819, ignoring one element. It seems better to round up with math.ceil(4096/5.0)
, which returns 820 VLANs per column.
The range header was using the forloop.counter
rather than the vlan
variable; which was incorrect and also led to the previous sixth column showing as a lesser number than the last VLAN in the previous range... Example:
From 15... ▲
17
18
19
20
21
From 20... ▲
22
23
120
1999
3004
From 25... ▲
(empty)
This was changed to be adequate to the last used VLAN+1 (3005
in this case). This is not completely adequate, as allocated VLANs need not to be consecutive.
File: optin_manager/src/python/openflow/optin_manager/opts/views.py
'vlan_list_length': math_ceil(len(allocated_vlans)/5.0),
File: optin_manager/src/templates/default/openflow/optin_manager/opts/admin_opt_in.html
<h3>VLAN(s) already allocated:</h3>
<div class="roundBlockContainer">
{% if allocated_vlans %}
{% for vlan in allocated_vlans %}
{% if forloop.first %}
<div class="vlan_list">
<ul style="margin:7px; padding:0px;">
<li><a id="vlan_range_{{forloop.counter0}}" class="expandableCtl header_vlan" href="#/">From {{forloop.counter0}}... <span class="closed">▼</span></a></li>
</ul>
<div class="expandable" id="vlan_range_{{forloop.counter0}}Container">
<ul>
{% endif %}
<li id="il_{{vlan}}" type="disc">{{vlan|safe}}</li>
{# Last iteration: close list and get out #}
{% if forloop.last %}
</ul>
</div>
</div>
{% else %}
{% if vlan_list_length != 0 and forloop.counter|divisibleby:vlan_list_length %}
</ul>
</div>
</div>
{# Same as before #}
<div class="vlan_list">
<ul style="margin:7px; padding:0px;">
{# Show "next" allocated VLAN (assuming consequent VLANs! - could be improved #}
<li><a id="vlan_range_{{vlan|add:"1"}}" class="expandableCtl header_vlan" href="#/">From {{vlan|add:"1"}}... <span class="closed">▼</span></a></li>
</ul>
<div class="expandable" id="vlan_range_{{vlan|add:"1"}}Container">
<ul>
{% endif %}
{% endif %}
{% endfor %}
{% else %}
The whole range of VLANs is available (Except the UNALLOWED VLANS).
{% endif %}
</div>
In the add rule page in Optin, the lists presenting the used VLANs are calculated wrongly. Their range is larger than it should be.