Updates collection item add/remove handlers

This commit is contained in:
Mouse Reeve 2021-04-08 15:22:06 -07:00
parent 43f0d4e603
commit 24685187e8

View file

@ -145,15 +145,6 @@ class Add(Verb):
object: CollectionItem
type: str = "Add"
def action(self):
""" add obj to collection """
target = resolve_remote_id(self.target, refresh=False)
# we want to get the related field that isn't the book, this is janky af sorry
model = [t for t in type(target)._meta.related_objects if t.name != "edition"][
0
].related_model
self.to_model(model=model)
@dataclass(init=False)
class Remove(Add):
@ -163,11 +154,7 @@ class Remove(Add):
def action(self):
""" find and remove the activity object """
target = resolve_remote_id(self.target, refresh=False)
model = [t for t in type(target)._meta.related_objects if t.name != "edition"][
0
].related_model
obj = self.to_model(model=model, save=False, allow_create=False)
obj = self.object.to_model(model=model, save=False, allow_create=False)
obj.delete()