Skip to content

Commit

Permalink
Règle un problème d'affichage des votes dans les MPs
Browse files Browse the repository at this point in the history
  • Loading branch information
Migwel committed Aug 12, 2022
1 parent 5ea18c2 commit bd140e8
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion zds/mp/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
from zds.mp.utils import send_mp, send_message_mp
from zds.utils.paginator import ZdSPagingListView
from .forms import PrivateTopicForm, PrivatePostForm, PrivateTopicEditForm
from .models import PrivateTopic, PrivateTopicRead, PrivatePost, mark_read, NotReachableError
from .models import PrivateTopic, PrivateTopicRead, PrivatePost, mark_read, NotReachableError, PrivatePostVote


class PrivateTopicList(ZdSPagingListView):
Expand Down Expand Up @@ -255,6 +255,10 @@ def get_context_data(self, **kwargs):
else:
context["user_can_modify"] = []

votes = PrivatePostVote.objects.filter(user_id=self.request.user.pk, private_post__in=context["posts"]).all()
context["user_like"] = [vote.private_post_id for vote in votes if vote.positive]
context["user_dislike"] = [vote.private_post_id for vote in votes if not vote.positive]

return context

def get_queryset(self):
Expand Down

0 comments on commit bd140e8

Please sign in to comment.