Opened 5 years ago

Closed 3 years ago

#16524 closed New feature (wontfix)

Add a manager/queryset method in contrib.comments to fetch comments not in moderation

Reported by: mat Owned by: justinlilly
Component: contrib.comments Version: master
Severity: Normal Keywords:
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: yes
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no


django.contrib.comments has a query to fetch all comments that are not in moderation, i.e. all the "publicly viewable" comments.
It's hidden inside the BaseCommentNode class in templatetags/comments though, which means developers using django.contrib.comments wanting to fetch publicly viewable comments outside of a templatetag context must violate DRY and copy/paste the filters themselves.

Attached is a patch that moves this code to a manager/queryset method, and that pass all current tests. It also makes possible to use the other manager methods (in_moderation, for_model) as queryset methods.

Attachments (2)

comments-add-queryset-methods.diff (3.6 KB) - added by mat 5 years ago.
16524.diff (4.6 KB) - added by justinlilly 5 years ago.

Download all attachments as: .zip

Change History (9)

Changed 5 years ago by mat

comment:1 Changed 5 years ago by mat

  • Has patch set
  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset

comment:2 Changed 5 years ago by justinlilly

  • Owner changed from nobody to anonymous
  • Status changed from new to assigned
  • Triage Stage changed from Unreviewed to Ready for checkin

Added a pull request.

@mat, in the future, your diffs should be relative to the repository root (ie: the folder with a django and tests folder in it).

comment:3 Changed 5 years ago by jezdez

  • Needs documentation set
  • Needs tests set
  • Triage Stage changed from Ready for checkin to Accepted
  • Type changed from Uncategorized to New feature

Please also attach an up-to-date patch with your changes. Also needs docs and tests.

comment:4 Changed 5 years ago by mat

Sadly, I currently lack the time to finish/improve my patch. If someone wants to work on this, feel free!

Changed 5 years ago by justinlilly

comment:5 Changed 5 years ago by justinlilly

  • Needs documentation unset
  • Needs tests unset
  • Owner changed from anonymous to justinlilly
  • Status changed from assigned to new

Most of the tests for comment managers still apply here. The current documentation still applies. If you can make a more targeted suggestion for which docs to provide, I'll happily add them, but I think the current document is adequate.

comment:6 Changed 5 years ago by jezdez

  • Needs documentation set

You add several model manager methods which simply need to be documented to be of any use.

comment:7 Changed 3 years ago by jacob

  • Resolution set to wontfix
  • Status changed from new to closed

django.contrib.comments has been deprecated and is no longer supported, so I'm closing this ticket. We're encouraging users to transition to a custom solution, or to a hosted solution like Disqus.

The code itself has moved to; if you want to keep using it, you could move this bug over there.

Note: See TracTickets for help on using tickets.
Back to Top