def reply_this(self, user, text): """Handler function to create a News instance as a reply to any published news. :requires: :param user: The logged in user who is doing the reply. :param content: String with the reply. """ parent = self.get_parent() # reply_news = News.objects.create( # user=user, content=text, reply=True, parent=parent # ) reply_community = Community.objects.create( user=user, content=text, reply=True, parent=parent ) notification_handler( user, parent.user, Notification.REPLY, # action_object=reply_news, action_object=reply_community, id_value=str(parent.uuid_id), key="social_update_community", )
def test_single_notification(self): Notification.objects.mark_all_as_read() obj = News.objects.create( user=self.user, content="This is a short content." ) notification_handler(self.user, self.other_user, "C", action_object=obj) assert Notification.objects.unread().count() == 1
def switch_like(self, user): if user in self.liked.all(): self.liked.remove(user) else: self.liked.add(user) notification_handler(user, self.user, Notification.LIKED, action_object=self, id_value=str(self.uuid_id), key='social_update')
def notify_comment(**kwargs): """Handler to be fired up upon comments signal to notify the author of a given article.""" actor = kwargs['request'].user receiver = kwargs['comment'].content_object.user obj = kwargs['comment'].content_object notification_handler(actor, receiver, Notification.COMMENTED, action_object=obj)
def switch_like(self, user): if user in self.liked.all(): self.liked.remove(user) else: self.liked.add(user) notification_handler(user, self.user, Notification.LIKED, action_object=self, id_value=str(self.uuid_id), key='social_update')
def reply_this(self, user, text): parent = self.get_parent() reply_news = News.objects.create( user=user, content=text, reply=True, parent=parent ) notification_handler( user, parent.user, Notification.REPLY, action_object=reply_news, id_value=str(parent.uuid_id), key='social_update')
def switch_attend(self, user): if user in self.attended.all(): self.attended.remove(user) else: self.attended.add(user) notification_handler( user, self.user, Notification.ATTENDED, action_object=self, id_value=str(self.uuid_id), key="social_update", )
def switch_like(self, user): if user in self.liked.all(): self.liked.remove(user) else: self.liked.add(user) print(type(self.content)) print(re.search('<h5>(.*)</h5>', self.content)) notification_handler( user, self.user, Notification.LIKED, action_object=self, # action_object=(re.search('<h5>(.*)</h5>',self.content)).group(1), id_value=str(self.uuid_id), key="social_update", )
def reply_this(self, user, text): """Handler function to create a News instance as a reply to any published news. :requires: :param user: The logged in user who is doing the reply. :param content: String with the reply. """ parent = self.get_parent() reply_news = News.objects.create( user=user, content=text, reply=True, parent=parent ) notification_handler( user, parent.user, Notification.REPLY, action_object=reply_news, id_value=str(parent.uuid_id), key='social_update')
def broadcast_logout(sender, user, request, **kwargs): """Handler to be fired up upon user logout signal to notify all users.""" notification_handler(user, "global", Notification.LOGGED_OUT)
def test_list_notification(self): Notification.objects.mark_all_as_read() notification_handler(self.user, [self.user, self.other_user], "C") assert Notification.objects.unread().count() == 2
def test_global_notification(self): Notification.objects.mark_all_as_read() notification_handler(self.user, "global", "C") assert Notification.objects.unread().count() == 1
def test_list_notification(self): Notification.objects.mark_all_as_read() notification_handler(self.user, [self.user, self.other_user], "C") assert Notification.objects.unread().count() == 2
def test_global_notification(self): Notification.objects.mark_all_as_read() notification_handler(self.user, "global", "C") assert Notification.objects.unread().count() == 1
def broadcast_logout(sender, user, request, **kwargs): """Handler to be fired up upon user logout signal to notify all users.""" notification_handler(user, "global", Notification.LOGGED_OUT)