diff options
author | adityacp | 2020-04-27 14:48:12 +0530 |
---|---|---|
committer | adityacp | 2020-04-27 14:48:12 +0530 |
commit | bfd33c397d30c60cde16d5073382bdae94d475cd (patch) | |
tree | 827cdf9bd0f4d02298eb3f81fa5af8dc3a10bfcb /yaksh/views.py | |
parent | 53a0c4ad3e733f3960000527f83565f2fd8fc412 (diff) | |
download | online_test-bfd33c397d30c60cde16d5073382bdae94d475cd.tar.gz online_test-bfd33c397d30c60cde16d5073382bdae94d475cd.tar.bz2 online_test-bfd33c397d30c60cde16d5073382bdae94d475cd.zip |
Fix pagination for forum post search
Diffstat (limited to 'yaksh/views.py')
-rw-r--r-- | yaksh/views.py | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/yaksh/views.py b/yaksh/views.py index 397e7c8..36a2fd2 100644 --- a/yaksh/views.py +++ b/yaksh/views.py @@ -3291,12 +3291,14 @@ def course_forum(request, course_id): if (not course.is_creator(user) and not course.is_teacher(user) and not course.is_student(user)): raise Http404('You are not enrolled in {0} course'.format(course.name)) - if 'search' in request.GET: - search_term = request.GET['search'] - posts = course.post.filter(active=True, title__icontains=search_term) + search_term = request.GET.get('search_post') + if search_term: + posts = course.post.get_queryset().filter( + active=True, title__icontains=search_term) else: - posts = course.post.filter(active=True).order_by('-modified_at') - paginator = Paginator(posts, 10) + posts = course.post.get_queryset().filter( + active=True).order_by('-modified_at') + paginator = Paginator(posts, 1) page = request.GET.get('page') posts = paginator.get_page(page) if request.method == "POST": @@ -3314,7 +3316,6 @@ def course_forum(request, course_id): 'user': user, 'course': course, 'base_template': base_template, - 'posts': posts, 'moderator': moderator, 'objects': posts, 'form': form, |