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.

This commit is contained in:
blitzmann
2015-07-02 11:22:26 -04:00
parent 717080b58c
commit e1ce672569
3 changed files with 8 additions and 8 deletions

View File

@@ -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)),

View File

@@ -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:

View File

@@ -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"""