Skip to content
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

Open
wants to merge 14 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add ordering when fetching PostReactions
  • Loading branch information
stopnoanime committed Jan 9, 2025
commit 1b4dbf11f28c7f3705d92223697f25ed3054f6e6
8 changes: 7 additions & 1 deletion oioioi/forum/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,10 @@ def get_queryset(self):
models.Prefetch(
'reactions',
to_attr=attr_name,
queryset=PostReaction.objects.filter(type_of_reaction=rtype).select_related('author')[:max_count],
queryset=PostReaction.objects
.filter(type_of_reaction=rtype)
.order_by('-pk')
.select_related('author')[:max_count],
)
)

Expand Down Expand Up @@ -282,6 +285,9 @@ def is_reporter_banned(self):
class PostReaction(models.Model):
"""PostReaction - represents a reaction to a post on the forum."""

class Meta(object):
ordering = ['-pk']

post = models.ForeignKey(
Post,
verbose_name=_("post"),
Expand Down
Loading