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

fix: the function all_ap_in doesn't crash anymore on dormitory use

This commit is contained in:
chirac 2021-01-24 14:19:42 +01:00 committed by chirac
parent 175a7e1baf
commit 5ea8e3d6d1
2 changed files with 7 additions and 7 deletions

View file

@ -129,17 +129,17 @@ class AccessPoint(Machine):
return str(self.interface_set.first().domain.name)
@classmethod
def all_ap_in(cls, building_instance):
"""Get all the APs of the given building.
def all_ap_in(cls, building_set):
"""Get all the APs of the given building set.
Args:
building_instance: the building used to find APs.
building_set: the building set used to find APs.
Returns:
The queryset of all APs in the given building.
The queryset of all APs in the given building set.
"""
return cls.objects.filter(
interface__port__switch__switchbay__building=building_instance
interface__port__switch__switchbay__building__in=building_set
)
def __str__(self):
@ -770,7 +770,7 @@ class Building(AclMixin, RevMixin, models.Model):
def all_ap_in(self):
"""Get all the APs in the building."""
return AccessPoint.all_ap_in(self)
return AccessPoint.all_ap_in(Building.objects.filter(id=self.id))
def get_name(self):
if Dormitory.is_multiple_dorms():

View file

@ -1331,7 +1331,7 @@ def make_machine_graph():
{"numero": port.port, "related": port.related.switch.get_name}
)
for ap in AccessPoint.all_ap_in(building).prefetch_related(
for ap in building.all_ap_in().prefetch_related(
Prefetch(
"interface_set",
queryset=(