Ejemplo n.º 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)
Ejemplo n.º 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)
Ejemplo n.º 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)
Ejemplo n.º 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)
Ejemplo n.º 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)
Ejemplo n.º 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')
Ejemplo n.º 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)
Ejemplo n.º 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)
Ejemplo n.º 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')
Ejemplo n.º 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)
Ejemplo n.º 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)
Ejemplo n.º 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)
Ejemplo n.º 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)
Ejemplo n.º 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)
Ejemplo n.º 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)
Ejemplo n.º 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)
Ejemplo n.º 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)
Ejemplo n.º 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)
Ejemplo n.º 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')
Ejemplo n.º 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')
Ejemplo n.º 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)
Ejemplo n.º 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)