Beispiel #1
0
    def __init__(self, up_votes, handler):
        def wrapper(sender, instance, **kwargs):
            if sender is Answer:
                if (not kwargs['field'] == "score") or (kwargs['new'] < kwargs['old']):
                    return

                answer = instance.leaf
                vote_count = kwargs['new']
            else:
                answer = instance.content_object
                vote_count = answer.vote_up_count

            if answer.accepted and vote_count == up_votes:
                handler(answer)

        activity_record.connect(wrapper, sender=const.TYPE_ACTIVITY_MARK_ANSWER, weak=False)
        denorm_update.connect(wrapper, sender=Node, weak=False)
Beispiel #2
0
 def __init__(self, model, field, expected_value, handler):
     def wrapper(instance, sfield, old, new, **kwargs):
         if sfield == field and (new == expected_value) or (old < expected_value and new > expected_value):
             handler(instance=instance)
     
     denorm_update.connect(wrapper, sender=model, weak=False)