Example #1
0
    def notify_upvoted_answer(self, answer):
        if self.user != answer.user:
            Notification(notification_type=Notification.UPVOTED_A,
                         from_user=self.user,
                         to_user=answer.user,
                         answer=answer).save()

        self.group_notification('upvoted_answer')
Example #2
0
    def notify_upvoted_question(self, question):
        if self.user != question.user:
            Notification(notification_type=Notification.UPVOTED_Q,
                         from_user=self.user,
                         to_user=question.user,
                         question=question).save()

        self.group_notification('upvoted_question')
Example #3
0
    def notify_accepted(self, answer):
        if self.user != answer.user:
            Notification(notification_type=Notification.ACCEPTED_ANSWER,
                         from_user=self.user,
                         to_user=answer.user,
                         answer=answer).save()

        self.group_notification('accepted_answer')
Example #4
0
    def notify_answered(self, question):
        if self.user != question.user:
            Notification(notification_type=Notification.ANSWERED,
                         from_user=self.user,
                         to_user=question.user,
                         question=question).save()

        self.group_notification('answered')
Example #5
0
    def notify_favorited(self, question):
        if self.user != question.user:
            Notification(notification_type=Notification.FAVORITED,
                         from_user=self.user,
                         to_user=question.user,
                         question=question).save()

        self.group_notification('favorited')
Example #6
0
    def notify_commented(self, feed):
        if self.user != feed.user:
            Notification(notification_type=Notification.COMMENTED,
                         from_user=self.user,
                         to_user=feed.user,
                         feed=feed).save()

        self.group_notification('commented')
        feed.feed_log('commented')
Example #7
0
    def notify_liked(self, feed):
        if self.user != feed.user:
            Notification(notification_type=Notification.LIKED,
                         from_user=self.user,
                         to_user=feed.user,
                         feed=feed).save()

        self.group_notification('liked')
        feed.feed_log('liked')
Example #8
0
    def notify_also_commented(self, feed):
        comments = feed.get_comments()
        users = []
        for comment in comments:
            if comment.user != self.user and comment.user != feed.user:
                users.append(comment.user.pk)

        users = list(set(users))
        for user in users:
            Notification(notification_type=Notification.ALSO_COMMENTED,
                         from_user=self.user,
                         to_user=User(id=user),
                         feed=feed).save()