summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--modules/tracking.py21
1 files changed, 12 insertions, 9 deletions
diff --git a/modules/tracking.py b/modules/tracking.py
index 72fbfc5..8995fdf 100644
--- a/modules/tracking.py
+++ b/modules/tracking.py
@@ -185,17 +185,20 @@ class Module:
msg = None
try:
session = Session()
- consignment = session.query(Consignment).filter(or_(Consignment.code == code, Consignment.label == code))
+ consignments = session.query(Consignment).filter(or_(Consignment.code == code, Consignment.label == code))
if nick:
- consignment = consignment.filter(Consignment.nick == nick)
- consignment = consignment.one()
- code = consignment.code
- for p in consignment.packages:
- session.delete(p)
- label = (' (%s)' % consignment.label) if consignment.label else ''
- session.delete(consignment)
+ consignments = consignments.filter(Consignment.nick == nick)
+ deleted = []
+ # we should have exactly one consignment, but need to handle cases when there are more
+ for consignment in consignments:
+ code = consignment.code
+ for p in consignment.packages:
+ session.delete(p)
+ label = (' (%s)' % consignment.label) if consignment.label else ''
+ deleted.append('\002%s\002%s' % (code.decode('utf8'), label))
+ session.delete(consignment)
session.commit()
- msg = 'No longer tracking \002%s\002%s' % (code.decode('utf8'), label)
+ msg = 'No longer tracking %s' % ', '.join(deleted)
except NoResultFound:
msg = '\002%s\002 is not being tracked.' % code.decode('utf8')
finally: