summaryrefslogtreecommitdiff
path: root/yaksh/views.py
diff options
context:
space:
mode:
authorCruiseDevice2020-04-26 22:21:41 +0530
committerCruiseDevice2020-04-26 22:21:41 +0530
commite261686554ad339449ba9fec6c2391faaefc0eff (patch)
treeaf0b9a23ab349ff4db69d852a6d7a0a40308b1e0 /yaksh/views.py
parent058724fb4b78774d8caeb2c0fbf53257ab00def7 (diff)
downloadonline_test-e261686554ad339449ba9fec6c2391faaefc0eff.tar.gz
online_test-e261686554ad339449ba9fec6c2391faaefc0eff.tar.bz2
online_test-e261686554ad339449ba9fec6c2391faaefc0eff.zip
Add search bar in forum to search posts
Diffstat (limited to 'yaksh/views.py')
-rw-r--r--yaksh/views.py7
1 files changed, 5 insertions, 2 deletions
diff --git a/yaksh/views.py b/yaksh/views.py
index cd53d55..be33a5e 100644
--- a/yaksh/views.py
+++ b/yaksh/views.py
@@ -3206,8 +3206,11 @@ 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))
- sort = request.GET.get('desc')
- posts = course.post.filter(active=True).order_by('-modified_at')
+ if 'search' in request.GET:
+ search_term = request.GET['search']
+ posts = course.post.filter(active=True, title__icontains=search_term)
+ else:
+ posts = course.post.filter(active=True).order_by('-modified_at')
paginator = Paginator(posts, 10)
page = request.GET.get('page')
posts = paginator.get_page(page)