mirror of
https://gitlab2.federez.net/re2o/re2o
synced 2024-11-23 20:03:11 +00:00
Optimise le chargement des chambres
This commit is contained in:
parent
5034c2656c
commit
e17b28cae0
2 changed files with 9 additions and 6 deletions
|
@ -611,16 +611,19 @@ class Building(AclMixin, RevMixin, models.Model):
|
||||||
"""Returns all ap of the building"""
|
"""Returns all ap of the building"""
|
||||||
return AccessPoint.all_ap_in(self)
|
return AccessPoint.all_ap_in(self)
|
||||||
|
|
||||||
@cached_property
|
def get_name(self):
|
||||||
def cached_name(self):
|
|
||||||
return self.__str__()
|
|
||||||
|
|
||||||
def __str__(self):
|
|
||||||
if Dormitory.objects.count() > 1:
|
if Dormitory.objects.count() > 1:
|
||||||
return self.dormitory.name + " : " + self.name
|
return self.dormitory.name + " : " + self.name
|
||||||
else:
|
else:
|
||||||
return self.name
|
return self.name
|
||||||
|
|
||||||
|
@cached_property
|
||||||
|
def cached_name(self):
|
||||||
|
return self.get_name()
|
||||||
|
|
||||||
|
def __str__(self):
|
||||||
|
return self.cached_name
|
||||||
|
|
||||||
|
|
||||||
class Port(AclMixin, RevMixin, models.Model):
|
class Port(AclMixin, RevMixin, models.Model):
|
||||||
""" Definition d'un port. Relié à un switch(foreign_key),
|
""" Definition d'un port. Relié à un switch(foreign_key),
|
||||||
|
|
|
@ -217,7 +217,7 @@ def index_port(request, switch, switchid):
|
||||||
@can_view_all(Room)
|
@can_view_all(Room)
|
||||||
def index_room(request):
|
def index_room(request):
|
||||||
""" Affichage de l'ensemble des chambres"""
|
""" Affichage de l'ensemble des chambres"""
|
||||||
room_list = Room.objects
|
room_list = Room.objects.select_related('building__dormitory')
|
||||||
room_list = SortTable.sort(
|
room_list = SortTable.sort(
|
||||||
room_list,
|
room_list,
|
||||||
request.GET.get('col'),
|
request.GET.get('col'),
|
||||||
|
|
Loading…
Reference in a new issue