Adds actions for all verbs

This commit is contained in:
Mouse Reeve
2021-02-15 20:49:23 -08:00
parent 12a3aa9667
commit a16b81a6eb
7 changed files with 507 additions and 506 deletions

View File

@ -12,6 +12,10 @@ class Verb(ActivityObject):
actor: str
object: ActivityObject
def action(self):
''' usually we just want to save, this can be overridden as needed '''
self.object.to_model()
@dataclass(init=False)
class Create(Verb):
@ -21,10 +25,6 @@ class Create(Verb):
signature: Signature = None
type: str = 'Create'
def action(self):
''' create the model instance from the dataclass '''
self.object.to_model()
@dataclass(init=False)
class Delete(Verb):
@ -33,6 +33,12 @@ class Delete(Verb):
cc: List
type: str = 'Delete'
def action(self):
''' find and delete the activity object '''
obj = self.object.to_model(save=False, allow_create=False)
obj.delete()
@dataclass(init=False)
class Update(Verb):
@ -40,12 +46,21 @@ class Update(Verb):
to: List
type: str = 'Update'
def action(self):
''' update a model instance from the dataclass '''
self.object.to_model(allow_create=False)
@dataclass(init=False)
class Undo(Verb):
''' Undo an activity '''
type: str = 'Undo'
def action(self):
''' find and remove the activity object '''
obj = self.object.to_model(save=False, allow_create=False)
obj.delete()
@dataclass(init=False)
class Follow(Verb):
@ -53,18 +68,25 @@ class Follow(Verb):
object: str
type: str = 'Follow'
@dataclass(init=False)
class Block(Verb):
''' Block activity '''
object: str
type: str = 'Block'
@dataclass(init=False)
class Accept(Verb):
''' Accept activity '''
object: Follow
type: str = 'Accept'
def action(self):
''' find and remove the activity object '''
obj = self.object.to_model(save=False, allow_create=False)
obj.accept()
@dataclass(init=False)
class Reject(Verb):
@ -72,6 +94,11 @@ class Reject(Verb):
object: Follow
type: str = 'Reject'
def action(self):
''' find and remove the activity object '''
obj = self.object.to_model(save=False, allow_create=False)
obj.reject()
@dataclass(init=False)
class Add(Verb):
@ -101,3 +128,8 @@ class Remove(Verb):
'''Remove activity '''
target: ActivityObject
type: str = 'Remove'
def action(self):
''' find and remove the activity object '''
obj = self.object.to_model(save=False, allow_create=False)
obj.delete()