Filter comment documents by current language
[edumed.git] / comment / views.py
1 from django.views.generic import ListView, DetailView
2 from django.conf import settings
3 from django.utils.translation import get_language
4
5 from .models import CommentDocument
6
7
8 class CommentDocumentList(ListView):
9     model = CommentDocument
10
11     def get_queryset(self, **kwargs):
12         return super(CommentDocumentList, self).get_queryset(**kwargs).filter(language_code = get_language())
13
14
15 class CommentDocument(DetailView):
16     model = CommentDocument
17
18     def get_context_data(self, **kwargs):
19         context = super(CommentDocument, self).get_context_data(**kwargs)
20         context['comment_url'] = settings.COMMENT_URL
21         return context