Exemplo n.º 1
0
def notify_comment(**kwargs):
    """Handler to be fired up upon comments signal to notify the author of a
    given article."""
    actor = kwargs['request'].user
    receiver = kwargs['comment'].content_object.user
    obj = kwargs['comment'].content_object
    notification_handler(actor,
                         receiver,
                         Notification.COMMENTED,
                         action_object=obj)
Exemplo n.º 2
0
    def switch_like(self, user):
        if user in self.liked.all():
            self.liked.remove(user)

        else:
            self.liked.add(user)
            notification_handler(user,
                                 self.user,
                                 Notification.LIKED,
                                 action_object=self,
                                 id_value=str(self.uuid_id),
                                 key='social_update')
Exemplo n.º 3
0
    def reply_this(self, user, text):
        """Handler function to create a News instance as a reply to any
        published news.

        :requires:

        :param user: The logged in user who is doing the reply.
        :param content: String with the reply.
        """
        parent = self.get_parent()
        reply_news = News.objects.create(user=user,
                                         content=text,
                                         reply=True,
                                         parent=parent)
        notification_handler(user,
                             parent.user,
                             Notification.REPLY,
                             action_object=reply_news,
                             id_value=str(parent.uuid_id),
                             key='social_update')
Exemplo n.º 4
0
def broadcast_logout(sender, user, request, **kwargs):
    """Handler to be fired up upon user logout signal to notify all users."""
    notification_handler(user, "global", Notification.LOGGED_OUT)