Ejemplo n.º 1
0
    def new_mention_notify(user, post = None, comment = None):
        """Create notify when user mentioned

        Keyword arguments:
        user -- User
        post -- Post
        comment - Comment

        Returns: Boolean
        """
        try:
            if post.author.username == user:
                return False
        except:
            if comment.author.username == user:
                return False
        try:
            usr = User.objects.get(username=user)
            try:
                Notify.objects.get(post=post, comment=comment, user=usr)
            except Notify.DoesNotExist:
                if usr.get_profile().reply_mention:
                    if post:
                       new_notify_email(post, 'post_mention', usr)
                    else:
                       new_notify_email(comment, 'mention', usr)
                if post:
                    notify = Notify(post=post, user=usr)
                else:
                    notify = Notify(comment=comment, user=usr)
                notify.save()
                return True
        except User.DoesNotExist:
            pass
Ejemplo n.º 2
0
    def new_mention_notify(user, post=None, comment=None):
        """Create notify when user mentioned

        Keyword arguments:
        user -- User
        post -- Post
        comment - Comment

        Returns: Boolean
        """
        try:
            if post.author.username == user:
                return False
        except:
            if comment.author.username == user:
                return False
        try:
            usr = User.objects.get(username=user)
            try:
                Notify.objects.get(post=post, comment=comment, user=usr)
            except Notify.DoesNotExist:
                if usr.get_profile().reply_mention:
                    if post:
                        new_notify_email(post, 'post_mention', usr)
                    else:
                        new_notify_email(comment, 'mention', usr)
                if post:
                    notify = Notify(post=post, user=usr)
                else:
                    notify = Notify(comment=comment, user=usr)
                notify.save()
                return True
        except User.DoesNotExist:
            pass
Ejemplo n.º 3
0
 def new_comment_notify(comment):
     """Notify for new comment
     
     Keyword arguments:
     comment -- Comment
     
     Returns: None
     
     """
     if comment.depth == 2:
         try:
             Notify.objects.get(comment=comment, user=comment.post.author)
         except Notify.DoesNotExist:
             print 'fuckfuckdie!'
             Notify.new_notify(False, comment, comment.post.author)
             if comment.post.author.get_profile().reply_post:
                 new_notify_email(comment, 'post_reply', comment.post.author)
             spy = Spy.objects.select_related('user').filter(post=comment.post)
             try:
                 for spy_elem in spy:
                     try:
                         Notify.objects.get(comment=comment, user=spy_elem.user)
                     except Notify.DoesNotExist:
                         Notify.new_notify(False, comment, spy_elem.user)
                         if spy_elem.user.get_profile().reply_spy:
                             new_notify_email(comment, 'spy_reply', spy_elem.user)
             except TypeError:
                 pass
     else:
         try:
             Notify.objects.get(comment=comment, user=comment.get_parent().author)
         except Notify.DoesNotExist:
             Notify.new_notify(False, comment, comment.get_parent().author)
             if comment.get_parent().author.get_profile().reply_comment:
                 new_notify_email(comment, 'comment_reply', comment.get_parent().author)
Ejemplo n.º 4
0
 def new_comment_notify(comment):
     """Notify for new comment
     
     Keyword arguments:
     comment -- Comment
     
     Returns: None
     
     """
     if comment.depth == 2:
         try:
             Notify.objects.get(comment=comment, user=comment.post.author)
         except Notify.DoesNotExist:
             Notify.new_notify(False, comment, comment.post.author)
             if comment.post.author.get_profile().reply_post:
                 new_notify_email(comment, 'post_reply',
                                  comment.post.author)
             spy = Spy.objects.select_related('user').filter(
                 post=comment.post)
             try:
                 for spy_elem in spy:
                     try:
                         Notify.objects.get(comment=comment,
                                            user=spy_elem.user)
                     except Notify.DoesNotExist:
                         Notify.new_notify(False, comment, spy_elem.user)
                         if spy_elem.user.get_profile().reply_spy:
                             new_notify_email(comment, 'spy_reply',
                                              spy_elem.user)
             except TypeError:
                 pass
     else:
         try:
             Notify.objects.get(comment=comment,
                                user=comment.get_parent().author)
         except Notify.DoesNotExist:
             Notify.new_notify(False, comment, comment.get_parent().author)
             if comment.get_parent().author.get_profile().reply_comment:
                 new_notify_email(comment, 'comment_reply',
                                  comment.get_parent().author)