-
Notifications
You must be signed in to change notification settings - Fork 82
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Forum] Display who upvoted/downvoted each post. Closes #346 #423
base: master
Are you sure you want to change the base?
Conversation
This PR has a bug that causes the latest posts view to not load. I turned the PR to a draft while I investigate why the tests didn't detect this. |
Added a test that checks the latest post view with reactions enabled. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks ok, but please add ordering + modify tests
models.Prefetch( | ||
'reactions', | ||
to_attr=attr_name, | ||
queryset=PostReaction.objects.filter(type_of_reaction=rtype).select_related('author')[:max_count], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it would be nice to add some ordering here, otherwise we can get random results (especially important during tests): i.e. order_by('-pk')
also you can add Meta class to PostReaction like:
class Meta:
ordering = ['-pk']
Displays usernames of users who upvoted/downvoted each post in a tooltip.
Only 10 usernames for each post are queried and displayed to improve performance.
I'm using prefetch_related to query necessary reactions for all posts with a single query.
Translation for a single string needs to be added, but afaik I can only do that in Transifex after this is merged?