示例#1
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')
示例#2
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')
示例#3
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')
示例#4
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')
示例#5
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')
示例#6
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')
示例#7
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')
示例#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()
示例#9
0
def last_notifications(request):
    user = request.user
    notifications = Notification.call_latest_notifications(user)
    return render(request,
                  'activities/last_notifications.html',
                  {'notifications': notifications})