From 46a0c6ee1c2655e3d7823b02866417ba50032287 Mon Sep 17 00:00:00 2001 From: Jon Bergli Heier Date: Mon, 17 Dec 2012 22:29:43 +0100 Subject: tracking: Also filter by package codes when stopping trackings. --- modules/tracking.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/modules/tracking.py b/modules/tracking.py index aaa0304..6fa01d7 100644 --- a/modules/tracking.py +++ b/modules/tracking.py @@ -220,11 +220,15 @@ class Module: msg = None try: session = Session() - consignments = session.query(Consignment).filter(and_(Consignment.server == self.irc.factory.server, - or_(Consignment.code == code, Consignment.label == code))) + consignments = session.query(Consignment).outerjoin(Consignment.packages) \ + .filter(and_(Consignment.server == self.irc.factory.server, + or_(Consignment.code == code, Consignment.label == code, Package.code == code))) if nick: consignments = consignments.filter(Consignment.nick == nick) deleted = [] + consignments = consignments.all() + if not len(consignments): + raise NoResultFound # we should have exactly one consignment, but need to handle cases when there are more for consignment in consignments: code = str(consignment) -- cgit v1.2.3