def notify_a_commented(self, answer): # working 3 if self.user != answer.user: a = Notification.objects.create(notification_type=Notification.COMMENTED, from_user=self.user, to_user=answer.user, answer=answer) tasks.notify_user(a.id, n=3)
def notify_q_commented(self, question): # working 2 if self.user != question.user: a = Notification.objects.create(notification_type=Notification.COMMENTED, from_user=self.user, to_user=question.user, question=question) tasks.notify_user(a.id, n=2)
def notify_also_joined(self, primary_workplace): # working 12 userprofiles = UserProfile.objects.filter(primary_workplace=primary_workplace) for userprofile in userprofiles: a = Notification.objects.create(notification_type=Notification.ALSO_JOINED, from_user=self.user, to_user=userprofile.user,) tasks.notify_user(a.id, n=12)
def notify_q_commented(self, question): # working 2 if self.user != question.user: a = Notification.objects.create( notification_type=Notification.COMMENTED, from_user=self.user, to_user=question.user, question=question) tasks.notify_user(a.id, n=2)
def notify_a_commented(self, answer): # working 3 if self.user != answer.user: a = Notification.objects.create( notification_type=Notification.COMMENTED, from_user=self.user, to_user=answer.user, answer=answer) tasks.notify_user(a.id, n=3)
def notify_n_commented(self, node): # working 4 print('shava') if self.user != node.user: a = Notification.objects.create(notification_type=Notification.COMMENTED, from_user=self.user, to_user=node.user, node=node) tasks.notify_user(a.id, n=4) print('dava')
def notify_a_downvoted(self, answer): # working 11 if self.user != answer.user: notified_user = answer.user.userprofile notified_user.points -= 5 notified_user.save() a = Notification.objects.create(notification_type=Notification.VotedDown, from_user=self.user, to_user=answer.user, answer=answer) tasks.notify_user(a.id, n=11)
def notify_q_downvoted(self, question): # working 9 if self.user != question.user: notified_user = question.user.userprofile notified_user.points -= 5 notified_user.save() a = Notification.objects.create(notification_type=Notification.VotedDown, from_user=self.user, to_user=question.user, question=question) tasks.notify_user(a.id, n=9)
def notify_n_commented(self, node): # working 4 print('shava') if self.user != node.user: a = Notification.objects.create( notification_type=Notification.COMMENTED, from_user=self.user, to_user=node.user, node=node) tasks.notify_user(a.id, n=4) print('dava')
def notify_liked(self, node): # working 1 if self.user != node.user: notified_user = node.user.userprofile notified_user.points += 5 notified_user.save() a = Notification.objects.create(notification_type=Notification.LIKED, from_user=self.user, to_user=node.user, node=node) tasks.notify_user(a.id, n=1)
def notify_liked(self, node): # working 1 if self.user != node.user: notified_user = node.user.userprofile notified_user.points += 5 notified_user.save() a = Notification.objects.create( notification_type=Notification.LIKED, from_user=self.user, to_user=node.user, node=node) tasks.notify_user(a.id, n=1)
def notify_also_joined(self, primary_workplace): # working 12 userprofiles = UserProfile.objects.filter( primary_workplace=primary_workplace) for userprofile in userprofiles: a = Notification.objects.create( notification_type=Notification.ALSO_JOINED, from_user=self.user, to_user=userprofile.user, ) tasks.notify_user(a.id, n=12)
def notify_q_downvoted(self, question): # working 9 if self.user != question.user: notified_user = question.user.userprofile notified_user.points -= 5 notified_user.save() a = Notification.objects.create( notification_type=Notification.VotedDown, from_user=self.user, to_user=question.user, question=question) tasks.notify_user(a.id, n=9)
def notify_a_downvoted(self, answer): # working 11 if self.user != answer.user: notified_user = answer.user.userprofile notified_user.points -= 5 notified_user.save() a = Notification.objects.create( notification_type=Notification.VotedDown, from_user=self.user, to_user=answer.user, answer=answer) tasks.notify_user(a.id, n=11)
def notify_also_q_commented(self, question): # working 6 comments = question.get_comment_count() users = [] for comment in comments: if comment.user != self.user and comment.user != question.user: users.append(comment.user.pk) users = list(set(users)) for user in users: a = Notification.objects.create(notification_type=Notification.ALSO_COMMENTED, from_user=self.user, to_user=User(id=user), question=question) tasks.notify_user(a.id, n=6)
def notify_also_a_commented(self, answer): # working 7 comments = answer.get_comments() users = [] for comment in comments: if comment.user != self.user and comment.user != answer.user: users.append(comment.user.pk) users = list(set(users)) for user in users: a = Notification.objects.create(notification_type=Notification.ALSO_COMMENTED, from_user=self.user, to_user=User(id=user), answer=answer) tasks.notify_user(a.id, n=7)
def notify_also_a_commented(self, answer): # working 7 comments = answer.get_comments() users = [] for comment in comments: if comment.user != self.user and comment.user != answer.user: users.append(comment.user.pk) users = list(set(users)) for user in users: a = Notification.objects.create( notification_type=Notification.ALSO_COMMENTED, from_user=self.user, to_user=User(id=user), answer=answer) tasks.notify_user(a.id, n=7)
def notify_also_q_commented(self, question): # working 6 comments = question.get_comment_count() users = [] for comment in comments: if comment.user != self.user and comment.user != question.user: users.append(comment.user.pk) users = list(set(users)) for user in users: a = Notification.objects.create( notification_type=Notification.ALSO_COMMENTED, from_user=self.user, to_user=User(id=user), question=question) tasks.notify_user(a.id, n=6)
def notify_also_n_commented(self, node): # working 5 print('balle') comments = node.get_all_comments() users = [] for comment in comments: if comment.user != self.user and comment.user != node.user: users.append(comment.user.pk) users = list(set(users)) for user in users: a = Notification.objects.create(notification_type=Notification.ALSO_COMMENTED, from_user=self.user, to_user=User(id=user), node=node) tasks.notify_user(a.id, n=5) print('walle')
def notify_also_n_commented(self, node): # working 5 print('balle') comments = node.get_all_comments() users = [] for comment in comments: if comment.user != self.user and comment.user != node.user: users.append(comment.user.pk) users = list(set(users)) for user in users: a = Notification.objects.create( notification_type=Notification.ALSO_COMMENTED, from_user=self.user, to_user=User(id=user), node=node) tasks.notify_user(a.id, n=5) print('walle')
def notify_answered(self, question): # working 13 if self.user != question.user: a = Notification.objects.create(notification_type=Notification.ANSWERED, from_user=self.user, to_user=question.user, question=question) tasks.notify_user(a.id, n=13) answers = question.get_answers() answerers = [] for answer in answers: if self.user != answer.user: answerers.append(answer.user.pk) answerers = list(set(answerers)) for user in answerers: a = Notification.objects.create(notification_type=Notification.ANSWERED, # working 14 from_user=self.user, to_user=User(id=user), question=question) tasks.notify_user(a.id, n=14)
def notify_answered(self, question): # working 13 if self.user != question.user: a = Notification.objects.create( notification_type=Notification.ANSWERED, from_user=self.user, to_user=question.user, question=question) tasks.notify_user(a.id, n=13) answers = question.get_answers() answerers = [] for answer in answers: if self.user != answer.user: answerers.append(answer.user.pk) answerers = list(set(answerers)) for user in answerers: a = Notification.objects.create( notification_type=Notification.ANSWERED, # working 14 from_user=self.user, to_user=User(id=user), question=question) tasks.notify_user(a.id, n=14)