From 09e857fdf32c5572bc2eeb0c07e80877871daf1a Mon Sep 17 00:00:00 2001 From: Adrian Moennich Date: Tue, 21 Jan 2025 20:10:16 +0100 Subject: [PATCH] Labotel: Ignore divisions from deleted rooms --- labotel/indico_labotel/controllers.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/labotel/indico_labotel/controllers.py b/labotel/indico_labotel/controllers.py index 99b60560..534551ab 100644 --- a/labotel/indico_labotel/controllers.py +++ b/labotel/indico_labotel/controllers.py @@ -41,7 +41,10 @@ def _process(self): class RHDivisions(RHRoomBookingBase): def _process(self): - return jsonify(sorted(div for div, in db.session.query(Room.division.distinct()) if div)) + query = (db.session + .query(Room.division.distinct()) + .filter(~Room.is_deleted, Room.division != '')) # noqa: PLC1901 + return jsonify(sorted(div for div, in query)) class RHLabotelStats(RHProtected):