mirror of
https://gitlab2.federez.net/re2o/re2o
synced 2024-11-22 03:13:12 +00:00
Optimisation, essaye d'accélérer la création du form d'interface
Long pour beaucoup d'ip (5-15 sec pour un /16)
This commit is contained in:
parent
4491f56d6a
commit
f2a4f83710
2 changed files with 7 additions and 5 deletions
|
@ -43,8 +43,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
|||
var type_to_ipv4 = {
|
||||
type: [{% for type, iplist in type_to_ipv4.items %}"{{ type }}",{% endfor %}],
|
||||
iplist: [{% for type, iplist in type_to_ipv4.items %}
|
||||
[{% for ip in iplist %} {id:"{{ ip.id }}", ip:"{{ ip.ipv4 }}"},
|
||||
{% endfor %}], {% endfor %}
|
||||
[ {{ iplist | safe }} ], {% endfor %}
|
||||
]
|
||||
}
|
||||
$(document).ready(function() {
|
||||
|
|
|
@ -119,7 +119,8 @@ def new_machine(request, userid):
|
|||
return redirect("/users/profil/" + str(user.id))
|
||||
type_to_ipv4 = {}
|
||||
for t in interface.fields['type'].queryset :
|
||||
type_to_ipv4[str(t.id)] = IpList.objects.filter(interface__isnull=True).filter(ip_type=t.ip_type)
|
||||
iplist = IpList.objects.filter(interface__isnull=True).filter(ip_type=t.ip_type)
|
||||
type_to_ipv4[str(t.id)] = ','.join(['{id:"%s", ip:"%s"}' % (b.id, b.ipv4) for b in iplist])
|
||||
return form({'machineform': machine, 'interfaceform': interface, 'domainform': domain, 'type_to_ipv4': type_to_ipv4}, 'machines/machine.html', request)
|
||||
|
||||
@login_required
|
||||
|
@ -159,7 +160,8 @@ def edit_interface(request, interfaceid):
|
|||
return redirect("/users/profil/" + str(interface.machine.user.id))
|
||||
type_to_ipv4 = {}
|
||||
for t in interface_form.fields['type'].queryset :
|
||||
type_to_ipv4[str(t.id)] = IpList.objects.filter(interface__isnull=True).filter(ip_type=t.ip_type)
|
||||
iplist = IpList.objects.filter(interface__isnull=True).filter(ip_type=t.ip_type)
|
||||
type_to_ipv4[str(t.id)] = ','.join(['{id:"%s", ip:"%s"}' % (b.id, b.ipv4) for b in iplist])
|
||||
return form({'machineform': machine_form, 'interfaceform': interface_form, 'domainform': domain_form, 'type_to_ipv4': type_to_ipv4}, 'machines/machine.html', request)
|
||||
|
||||
@login_required
|
||||
|
@ -218,7 +220,8 @@ def new_interface(request, machineid):
|
|||
return redirect("/users/profil/" + str(machine.user.id))
|
||||
type_to_ipv4 = {}
|
||||
for t in interface_form.fields['type'].queryset :
|
||||
type_to_ipv4[str(t.id)] = IpList.objects.filter(interface__isnull=True).filter(ip_type=t.ip_type)
|
||||
iplist = IpList.objects.filter(interface__isnull=True).filter(ip_type=t.ip_type)
|
||||
type_to_ipv4[str(t.id)] = ','.join(['{id:"%s", ip:"%s"}' % (b.id, b.ipv4) for b in iplist])
|
||||
return form({'interfaceform': interface_form, 'domainform': domain_form, 'type_to_ipv4': type_to_ipv4}, 'machines/machine.html', request)
|
||||
|
||||
@login_required
|
||||
|
|
Loading…
Reference in a new issue