8
0
Fork 0
mirror of https://gitlab2.federez.net/re2o/re2o synced 2024-12-23 07:23:46 +00:00

Optimise le chargement des chambres

This commit is contained in:
Gabriel Detraz 2019-08-06 17:46:13 +02:00 committed by root
parent 5034c2656c
commit e17b28cae0
2 changed files with 9 additions and 6 deletions

View file

@ -611,16 +611,19 @@ class Building(AclMixin, RevMixin, models.Model):
"""Returns all ap of the building"""
return AccessPoint.all_ap_in(self)
@cached_property
def cached_name(self):
return self.__str__()
def __str__(self):
def get_name(self):
if Dormitory.objects.count() > 1:
return self.dormitory.name + " : " + self.name
else:
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):
""" Definition d'un port. Relié à un switch(foreign_key),

View file

@ -217,7 +217,7 @@ def index_port(request, switch, switchid):
@can_view_all(Room)
def index_room(request):
""" Affichage de l'ensemble des chambres"""
room_list = Room.objects
room_list = Room.objects.select_related('building__dormitory')
room_list = SortTable.sort(
room_list,
request.GET.get('col'),