def send_voted_activity_signal(sender, instance, created, **kwargs): """ Sends the "voted" activity to the stream on up/down vote Decisions: 1. The vote object isn't included in the stream 2. Activities are recorded even when votes are changed 3. The target of the vote verb is the content_object """ vote_verb = { 1: 'upvote', -1: 'downvote', 0: None }[instance.vote] if vote_verb is None: return voted = { 'sender': sender, 'actor': instance.user, 'verb': vote_verb, 'target': instance.content_object, } stream.send(**voted)
def send_joined_activity_signal(sender, instance, created, **kwargs): """ Sends the "joined" activity to the stream on create """ if created: joined = { 'sender': sender, 'actor': instance, 'verb': 'join', 'timestamp': instance.date_joined, } stream.send(**joined)
def send_asked_activity_signal(sender, instance, created, **kwargs): """ Sends the "asked" activity to the stream on Question create """ if created: joined = { 'sender': sender, 'actor': instance.author, 'verb': 'ask', 'target': instance, 'timestamp': instance.created, } stream.send(**joined)
def send_answered_activity_signal(sender, instance, created, **kwargs): """ Sends the "answered" activity to the stream on Question create """ if created: activity = { 'sender': sender, 'actor': instance.author, 'verb': 'answer', 'target': instance, 'timestamp': instance.created, } stream.send(**activity)
def send_answered_activity_signal(sender, instance, created, **kwargs): """ Sends the "answered" activity to the stream on Question create """ if created: activity = { 'sender': sender, 'actor': instance.author, 'verb': 'answer', 'theme': instance, 'target': instance.question, 'timestamp': instance.created, } stream.send(**activity)
def send_voted_activity_signal(sender, instance, created, **kwargs): """ Sends the "voted" activity to the stream on up/down vote Decisions: 1. The vote object isn't included in the stream 2. Activities are recorded even when votes are changed 3. The target of the vote verb is the content_object """ vote_verb = {1: 'upvote', -1: 'downvote', 0: None}[instance.vote] if vote_verb is None: return voted = { 'sender': sender, 'actor': instance.user, 'verb': vote_verb, 'target': instance.content_object, } stream.send(**voted)
def send_annotation_activity_signal(sender, instance, created, **kwargs): """ Sends the "annotated" activity to the stream on Annotation create or update """ # If no user, this is a parse annotation if instance.user is None: return activity = { 'sender': sender, 'actor': instance.user, 'verb': 'annotate', 'target': instance.question, 'timestamp': instance.modified, } # Topic can be null if instance.topic: activity['theme'] = instance.topic stream.send(**activity)