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')
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')
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')
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')
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')
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')
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')
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()
def last_notifications(request): user = request.user notifications = Notification.call_latest_notifications(user) return render(request, 'activities/last_notifications.html', {'notifications': notifications})