From e1ce67256951c52202baf07cd9f3bfe6fcd8e3e0 Mon Sep 17 00:00:00 2001 From: blitzmann Date: Thu, 2 Jul 2015 11:22:26 -0400 Subject: [PATCH] Move flag_modified to HandledList.remove() so that it takes care of all our use cases. Give fits an itemID like everything else so that projected fits can be removed correctly by this logic. No reason for them to be special snowflakes. --- eos/db/saveddata/fit.py | 2 ++ eos/effectHandlerHelpers.py | 12 +++++------- eos/saveddata/cargo.py | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/eos/db/saveddata/fit.py b/eos/db/saveddata/fit.py index 0677728d8..0c5edaee9 100644 --- a/eos/db/saveddata/fit.py +++ b/eos/db/saveddata/fit.py @@ -53,6 +53,8 @@ mapper(Fit, fits_table, "_Fit__projectedModules" : relation(Module, collection_class = HandledProjectedModList, cascade='all, delete, delete-orphan', single_parent=True, primaryjoin = and_(modules_table.c.fitID == fits_table.c.ID, modules_table.c.projected == True)), "owner" : relation(User, backref = "fits"), + "itemID" : fits_table.c.shipID, + "shipID" : fits_table.c.shipID, "_Fit__boosters" : relation(Booster, collection_class = HandledImplantBoosterList, cascade='all, delete, delete-orphan', single_parent=True), "_Fit__drones" : relation(Drone, collection_class = HandledDroneCargoList, cascade='all, delete, delete-orphan', single_parent=True, primaryjoin = and_(drones_table.c.fitID == fits_table.c.ID, drones_table.c.projected == False)), diff --git a/eos/effectHandlerHelpers.py b/eos/effectHandlerHelpers.py index 1311dcf6a..a417fa041 100644 --- a/eos/effectHandlerHelpers.py +++ b/eos/effectHandlerHelpers.py @@ -102,6 +102,11 @@ class HandledList(list): except AttributeError: pass + def remove(self, thing): + # We must flag it as modified, otherwise it not be removed from the database + flag_modified(thing, "itemID") + list.remove(self, thing) + class HandledModuleList(HandledList): def append(self, mod): emptyPosition = float("Inf") @@ -168,8 +173,6 @@ class HandledDroneCargoList(HandledList): HandledList.append(self, thing) if thing.isInvalid: - # we must flag it as modified, otherwise it will not be removed from the database - flag_modified(thing, "itemID") self.remove(thing) class HandledImplantBoosterList(HandledList): @@ -185,11 +188,6 @@ class HandledImplantBoosterList(HandledList): HandledList.append(self, thing) - def remove(self, thing): - # We must flag it as modified, otherwise it not be removed from the database - flag_modified(thing, "itemID") - HandledList.remove(self, thing) - class HandledProjectedModList(HandledList): def append(self, proj): if proj.isInvalid: diff --git a/eos/saveddata/cargo.py b/eos/saveddata/cargo.py index fa68de1a0..7f7542a0b 100644 --- a/eos/saveddata/cargo.py +++ b/eos/saveddata/cargo.py @@ -23,7 +23,7 @@ from sqlalchemy.orm import validates, reconstructor import eos.db -class Cargo(HandledItem, HandledCharge, ItemAttrShortcut, ChargeAttrShortcut): +class Cargo(HandledItem, ItemAttrShortcut): def __init__(self, item): """Initialize cargo from the program"""