database.session.commit()
database.session.begin()
- machines_no_access = database.session.query(database.Machine).filter(~database.Machine.acl.any()).all()
+ acl_locker_no_err = database.session.query(database.MachineAccess.machine_id).outerjoin(Locker, database.MachineAccess.user == Locker.name).filter((Locker.type == None) | (Locker.type != "ERR")).group_by(database.MachineAccess.machine_id).subquery()
+ machines_no_access = database.session.query(database.Machine).outerjoin(acl_locker_no_err).filter(acl_locker_no_err.c.machine_id == None).all()
machines_no_locker = database.session.query(database.Machine).join(Locker, database.Machine.owner == Locker.name).filter(Locker.type == None).all()
machines_err_locker = database.session.query(database.Machine, Locker.message).join(Locker, database.Machine.owner == Locker.name).filter(Locker.type == 'ERR').all()