Resolve and assign target collection for collection items

This commit is contained in:
Mouse Reeve
2021-04-08 15:40:02 -07:00
parent a7375c4c13
commit ddd05a68cf
2 changed files with 22 additions and 66 deletions

View File

@ -145,6 +145,13 @@ class Add(Verb):
object: CollectionItem
type: str = "Add"
def action(self):
""" figure out the target to assign the item to a collection """
target = resolve_remote_id(self.target)
item = self.object.to_model(save=False)
setattr(item, item.collection_field, target)
item.save()
@dataclass(init=False)
class Remove(Add):
@ -154,7 +161,7 @@ class Remove(Add):
def action(self):
""" find and remove the activity object """
obj = self.object.to_model(model=model, save=False, allow_create=False)
obj = self.object.to_model(save=False, allow_create=False)
obj.delete()