+ Base Action class. Must define following attributes:
+ ``alias``: unique identifier of this action
+ ``verb``: short action's verb
+ ``signal``: signal with which this action would be connected
+ ``sender``: sender class or object
+ Action classes must implement required, static method called ``action``
+ which in fact is standard Django signal handler.
+ def action(sender, **kwargs):
+ raise NotImplementedError
+ def connect_signal(cls):
+ cls.signal.connect(cls.action, sender=cls.sender)
alias = "project_created"
def action(sender, instance, created, **kwargs):
+ if created and not instance.parent:
+ alias = "project_forked"
+ def action(sender, instance, created, **kwargs):
if created and instance.parent:
- instance.parent.create_action("forked", author=instance.author)
- def connect_signal(self):
- self.signal.connect(ProjectAction.action, sender=ProjectAction.sender)
def action_project_created(sender, instance, created, **kwargs):
- for ActionClass in actions: