def resolve(self, src, obj): rule = self.rule # Create a hook when appropriate and give it the starting funds hook = None if rule.rerule: hook = rule.rerule.hooks.create(src=src, obj=obj) if not rule.value or rule.receiver == Rule.NONE: return # Create the hooks value by the app credits.move(rule.ruler, obj, rule.value, rule.currency) # Transfer the value to the user credits.move(obj, user, rule.value, rule.currency) if rule.receiver == Rule.SOURCE: # Notify any listeners that the user has received a fee signals.fee_signal.send(sender=hook, src=src, amount=rule.value, currency=rule.currency) elif rule.receiver == Rule.HOOK: if hook: credits.move(src, hook, rule.value, rule.currency) signals.hook_signal.send(sender=hook, src=src, obj=obj) else: credits.move(src, self, rule.value, rule.currency) signals.hook_signal.send(sender=self, src=src, obj=obj)
def boost(self, src, amount): return credits.move(src, self, amount, self.rule.currency)