示例#1
0
 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)
示例#2
0
 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)
示例#3
0
    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)
示例#4
0
 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)
示例#5
0
 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)
示例#6
0
 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')
示例#7
0
 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)
示例#8
0
 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)
示例#9
0
 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')
示例#10
0
 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)
示例#11
0
 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)
示例#12
0
    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)
示例#13
0
 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)
示例#14
0
 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)
示例#15
0
 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)
示例#16
0
 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)
示例#17
0
 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)
示例#18
0
 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)
示例#19
0
 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')
示例#20
0
 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')
示例#21
0
 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)
示例#22
0
 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)