8
0
Fork 0
mirror of https://gitlab2.federez.net/re2o/re2o synced 2024-11-26 22:52:26 +00:00

Optimise le chargement des machines

This commit is contained in:
Gabriel Detraz 2017-05-28 18:29:54 +02:00 committed by root
parent 724667cb85
commit 216547507e
2 changed files with 2 additions and 2 deletions

View file

@ -609,7 +609,7 @@ def del_alias(request, interfaceid):
@login_required @login_required
@permission_required('cableur') @permission_required('cableur')
def index(request): def index(request):
machines_list = Machine.objects.select_related('user').prefetch_related('interface_set__domain__extension').prefetch_related('interface_set__ipv4__ip_type__extension').prefetch_related('interface_set__type').order_by('pk') machines_list = Machine.objects.select_related('user').prefetch_related('interface_set__domain__extension').prefetch_related('interface_set__ipv4__ip_type__extension').prefetch_related('interface_set__type').prefetch_related('interface_set__domain__related_domain__extension').order_by('pk')
paginator = Paginator(machines_list, PAGINATION_LARGE_NUMBER) paginator = Paginator(machines_list, PAGINATION_LARGE_NUMBER)
page = request.GET.get('page') page = request.GET.get('page')
try: try:

View file

@ -614,7 +614,7 @@ def profil(request, userid):
if not request.user.has_perms(('cableur',)) and users != request.user: if not request.user.has_perms(('cableur',)) and users != request.user:
messages.error(request, "Vous ne pouvez pas afficher un autre user que vous sans droit cableur") messages.error(request, "Vous ne pouvez pas afficher un autre user que vous sans droit cableur")
return redirect("/users/profil/" + str(request.user.id)) return redirect("/users/profil/" + str(request.user.id))
machines = Machine.objects.filter(user__pseudo=users) machines = Machine.objects.filter(user__pseudo=users).select_related('user').prefetch_related('interface_set__domain__extension').prefetch_related('interface_set__ipv4__ip_type__extension').prefetch_related('interface_set__type').prefetch_related('interface_set__domain__related_domain__extension')
factures = Facture.objects.filter(user__pseudo=users) factures = Facture.objects.filter(user__pseudo=users)
bans = Ban.objects.filter(user__pseudo=users) bans = Ban.objects.filter(user__pseudo=users)
whitelists = Whitelist.objects.filter(user__pseudo=users) whitelists = Whitelist.objects.filter(user__pseudo=users)