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

Merge branch 'fix_ap_shortcut' into 'dev'

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

See merge request re2o/re2o!597
This commit is contained in:
Jean-Romain Garnier 2021-01-24 15:19:39 +01:00
commit 5b992e929d
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=(