def add_action(sender, created=False, instance=None, **kwargs): if not instance or not created: return action.send( _get_actor(instance, instance.added_by), verb=_get_verb(instance), action_object=instance, # action object, what was created place=instance.lot.centroid, # where did it happen? target=instance.lot, # what did it happen to? data={}, )
def add_action_post(sender, created=False, instance=None, **kwargs): """ Detect the addition of a (vacant) lot, add an action. """ if not (instance and created and instance.is_vacant): return action.send( None, verb='added a lot', target=instance, place=instance.centroid, description='new vacant lot added to database', administrative=True, action_type='lots.add_lot', )
def add_action_pre(sender, created=False, instance=None, **kwargs): """ Detect changes on a lot and add actions for the significant ones. """ if created or not instance: return try: old_instance = Lot.objects.get(pk=instance.pk) except Exception: return # If someone got access to the lot record an action if old_instance.group_has_access != instance.group_has_access: if instance.group_with_access: action.send( instance.group_with_access, verb='got access to', target=instance, place=instance.centroid, action_type='lots.group_got_access', )