summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--yaksh/templates/yaksh/course_forum.html28
-rw-r--r--yaksh/views.py7
2 files changed, 26 insertions, 9 deletions
diff --git a/yaksh/templates/yaksh/course_forum.html b/yaksh/templates/yaksh/course_forum.html
index bf098d3..dea4d8f 100644
--- a/yaksh/templates/yaksh/course_forum.html
+++ b/yaksh/templates/yaksh/course_forum.html
@@ -9,13 +9,27 @@
<h2><center>{{course.name}}</center></h2>
<center>Discussion Forum</center>
</div>
- {% if moderator %}
- <a href="{% url 'yaksh:course_detail' course.id %}" class="btn btn-primary">Back to Course</a>
- {% else %}
- <a href="{% url 'yaksh:course_modules' course.id %}" class="btn btn-primary">Back to Course</a>
- {% endif %}
- <div class="pull-right">
- <button type="button" class="btn btn-primary" data-toggle="modal" data-target="#newPostModal">New Post</button>
+ <div class="d-flex p-2 bd-highlight">
+ <div class="col-md-4">
+ {% if moderator %}
+ <a href="{% url 'yaksh:course_detail' course.id %}" class="btn btn-primary">Back to Course</a>
+ {% else %}
+ <a href="{% url 'yaksh:course_modules' course.id %}" class="btn btn-primary">Back to Course</a>
+ {% endif %}
+ </div>
+ <div class="col-md-4">
+ <form class="my-2 my-lg-0" action="" method="GET">
+ <div class="input-group">
+ <input type="search" placeholder="Search" name="search" class="form-control">
+ <span class="input-group-append">
+ <button class="btn btn-outline-info" type="submit"><i class="fa fa-search"></i>&nbsp;Search</button>
+ </span>
+ </div>
+ </form>
+ </div>
+ <div class="col-md-4">
+ <button type="button" class="btn btn-primary pull-right" data-toggle="modal" data-target="#newPostModal">New Post</button>
+ </div>
</div>
<!-- Modal -->
<div id="newPostModal" class="modal fade" role="dialog">
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)