DeeMcCart / CI_PP4_Financial_Planner

Financial_Planner: Authorative information on financial processes in Republic of Ireland
0 stars 1 forks source link

Comments: 'Your comment is awaiting approval' disappears for user1 when user2's comment is approved #28

Closed DeeMcCart closed 1 year ago

DeeMcCart commented 1 year ago

Describe the bug From user story/ issue #18 30/10/23 end of day - there is a small bug within comment processing. The bug is that if user1 creates a comment which is awaiting approval, the screen will initially display 'your comment is awaiting approval' and user1 (correctly) cannot add a second comment.
If user2 then creates a comment on the same article and gets the message 'your comment is awaiting approval', user2 then can't add additional comments (working correctly). However if EITHER comment is approved then the 'your comment is awaiting approval' message disappears for ALL users. This means that user1/user2 could then add more unapproved comments which pile up waiting for approval. Raised as a bug under issue [#25] but closed that out as had used the standard user story template & raised here instead.

To Reproduce user1 creates a comment which is awaiting approval, the screen will initially display 'your comment is awaiting approval' and user1 (correctly) cannot add a second comment.
If user2 then creates a comment on the same article and gets the message 'your comment is awaiting approval', user2 then can't add additional comments (working correctly). However if EITHER comment is approved then the 'your comment is awaiting approval' message disappears for ALL users. This means that user1/user2 could then add more unapproved comments which pile up waiting for approval. This can also be seen on the admin console where multiple comments for the same user/article start to accumulate

Expected behavior The message for a particular article/user combination will continue to show 'your comment is awaiting approval' if the user has any unapproved comments against this article. This prevents comments 'disappearing' and means that a user can have max 1 outstanding comment against an article.

Screenshots Admin view shows multiple unapproved comments for a particular article/ admin user: bug28-approving-any-comment-removes-comment-awaiting-approval-message-for-all-users-sp1

However when admin navigates to that article, no display of 'your message is awaiting approval' , and indeed the user could add a further (unapproved) message:

bug28-approving-any-comment-removes-comment-awaiting-approval-message-for-all-users-sp2 proving-any-comment-removes-comment-awaiting-approval-message-for-all-users-sp2

Additional context Add any other context about the problem here. 31/10/23 Tried using the following code snippet in views.py, but couldnt get an output to the console log: commented = False print('User ', self.request.user.id) if article.comments.filter(id=self.request.user.id, approved=False).exists(): print('Unapproved comments exist for this user!') commented = True

DeeMcCart commented 1 year ago

01/11/23: There could be a couple of approaches to resolve this problem:

DeeMcCart commented 1 year ago

`class ArticleDetail(View): def get(self, request, slug, *args, **kwargs): queryset = Article.objects.filter(status=1) article = get_object_or_404(queryset, slug=slug) comments = article.comments.filter(approved=True).order_by( '-created_on') actions = article.actions.order_by('action_seq') liked = False if article.likes.filter(id=self.request.user.id).exists(): liked = True commented = False print('User ', self.request.user.id) if article.comments.filter(id=self.request.user.id, approved=False).exists(): print('Unapproved comments exist for this user!') commented = True

    return render(
        request,
        "article_detail.html",
        {
         "article": article,
         "comments": comments,
         "commented": commented,
         "actions": actions,
         "liked": liked,
         "comment_form": CommentForm()
         },
    )

`

DeeMcCart commented 1 year ago

01/11/23 OK going to park this for now, perhaps it is working as designed... will do some research to see what is the norm....

DeeMcCart commented 1 year ago

02/11/23 Have done some research on comments and based on the overhead of 'facilitating healthy discussions, deleting spam, genuinely engaging with users and answering both on-topic and off-topic questions', as well as the low correlation between views/links and #comments on blog sites, I am going to take a different approach.
I don't really think comments add value to this particular site, as its USP is that it provides authoritive, non-vendor-driven financial advisory articles, and it does not lend weight to opinion-based but incorrect or poorly understood commentary - really the financial_planner site USP is about eliminating non-authorative or opinion-based information. Plenty of other blog sites offer opinion-sharing, so stick with authoritative, well-written content and provide practical, clear tools which users can make their own by personalising actions and bookmarking. ref articles: https://blog.hubspot.com/marketing/blog-comments https://optinmonster.com/to-allow-blog-comments-or-not-heres-what-the-data-shows/

MOVING THIS ISSUE TO 'DONE' AND will remove the commenting feature once CRUD is satistified within Release1 (Personal Financial Planner)