summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--yaksh/templates/yaksh/courses.html11
-rw-r--r--yaksh/templates/yaksh/paginator.html7
-rw-r--r--yaksh/test_views.py4
-rw-r--r--yaksh/views.py25
4 files changed, 24 insertions, 23 deletions
diff --git a/yaksh/templates/yaksh/courses.html b/yaksh/templates/yaksh/courses.html
index a590f8e..151e1fb 100644
--- a/yaksh/templates/yaksh/courses.html
+++ b/yaksh/templates/yaksh/courses.html
@@ -41,8 +41,7 @@
</div>
{% else %}
<hr>
- <form name=frm action="" method="post">
- {% csrf_token %}
+ <form name=frm action="" method="get">
<div class="card">
<div class="card-header">
<h3>Search/Filter Courses</h3>
@@ -57,9 +56,11 @@
</div>
</div>
<br>
- <button class="btn btn-success" type="submit">Search</button>
- <a class="btn btn-primary" href="{% url 'yaksh:courses' %}">
- Clear Search
+ <button class="btn btn-outline-success" type="submit">
+ <i class="fa fa-search"></i>&nbsp;Search
+ </button>
+ <a class="btn btn-outline-danger" href="{% url 'yaksh:courses' %}">
+ <i class="fa fa-times"></i>&nbsp;Clear
</a>
</div>
</div>
diff --git a/yaksh/templates/yaksh/paginator.html b/yaksh/templates/yaksh/paginator.html
index c634d5c..e958519 100644
--- a/yaksh/templates/yaksh/paginator.html
+++ b/yaksh/templates/yaksh/paginator.html
@@ -1,7 +1,8 @@
<ul class="pagination pagination">
{% if objects.has_previous %}
<li class="page-item">
- <a class="page-link" href="?page=1{% if request.GET.question_type %}&question_type={{ request.GET.question_type }}{% endif %}{% if request.GET.language %}&language={{ request.GET.language }}{% endif %}{% if request.GET.marks %}&marks={{ request.GET.marks }}{% endif %}{% if request.GET.question_tags %}&question_tags={{ request.GET.question_tags }}{% endif %}" aria-label="Previous">
+ <a class="page-link" href="?page=1{% if request.GET.question_type %}&question_type={{ request.GET.question_type }}{% endif %}{% if request.GET.language %}&language={{ request.GET.language }}{% endif %}{% if request.GET.marks %}&marks={{ request.GET.marks }}{% endif %}{% if request.GET.question_tags %}&question_tags={{ request.GET.question_tags }}{% endif %}
+ {% if request.GET.search_tags %}&search_tags={{ request.GET.search_tags }}{% endif %}{% if request.GET.search_status %}&search_status={{ request.GET.search_status }}{% endif %}" aria-label="Previous">
<span aria-hidden="true">
<i class="fa fa-angle-double-left"></i>
</span>
@@ -16,13 +17,13 @@
<span class="page-link">{{ n }}<span class="sr-only">(current)</span></span>
</li>
{% elif n > objects.number|add:'-5' and n < objects.number|add:'5' %}
- <li class="page-item"><a class="page-link" href="?page={{ n }}{% if request.GET.question_type %}&question_type={{ request.GET.question_type }}{% endif %}{% if request.GET.language %}&language={{ request.GET.language }}{% endif %}{% if request.GET.marks %}&marks={{ request.GET.marks }}{% endif %}{% if request.GET.question_tags %}&question_tags={{ request.GET.question_tags }}{% endif %}">{{ n }}</a></li>
+ <li class="page-item"><a class="page-link" href="?page={{ n }}{% if request.GET.question_type %}&question_type={{ request.GET.question_type }}{% endif %}{% if request.GET.language %}&language={{ request.GET.language }}{% endif %}{% if request.GET.marks %}&marks={{ request.GET.marks }}{% endif %}{% if request.GET.question_tags %}&question_tags={{ request.GET.question_tags }}{% endif %}{% if request.GET.search_tags %}&search_tags={{ request.GET.search_tags }}{% endif %}{% if request.GET.search_status %}&search_status={{ request.GET.search_status }}{% endif %}">{{ n }}</a></li>
{% endif %}
{% endfor %}
{% if objects.has_next %}
<li class="page-item">
- <a class="page-link" href="?page={{ objects.paginator.num_pages }}{% if request.GET.question_type %}&question_type={{ request.GET.question_type }}{% endif %}{% if request.GET.language %}&language={{ request.GET.language }}{% endif %}{% if request.GET.marks %}&marks={{ request.GET.marks }}{% endif %}{% if request.GET.question_tags %}&question_tags={{ request.GET.question_tags }}{% endif %}" aria-label="Next">
+ <a class="page-link" href="?page={{ objects.paginator.num_pages }}{% if request.GET.question_type %}&question_type={{ request.GET.question_type }}{% endif %}{% if request.GET.language %}&language={{ request.GET.language }}{% endif %}{% if request.GET.marks %}&marks={{ request.GET.marks }}{% endif %}{% if request.GET.question_tags %}&question_tags={{ request.GET.question_tags }}{% endif %}{% if request.GET.search_tags %}&search_tags={{ request.GET.search_tags }}{% endif %}{% if request.GET.search_status %}&search_status={{ request.GET.search_status }}{% endif %}" aria-label="Next">
<span aria-hidden="true">
<i class="fa fa-angle-double-right"></i>
</span>
diff --git a/yaksh/test_views.py b/yaksh/test_views.py
index 29a8542..ef7c52f 100644
--- a/yaksh/test_views.py
+++ b/yaksh/test_views.py
@@ -2367,9 +2367,9 @@ class TestSearchFilters(TestCase):
username=self.user1.username,
password=self.user1_plaintext_pass
)
- response = self.client.post(
+ response = self.client.get(
reverse('yaksh:courses'),
- data={'course_tags': 'demo', 'course_status': 'active'}
+ data={'search_tags': 'demo', 'search_status': 'active'}
)
self.assertEqual(response.status_code, 200)
self.assertTemplateUsed(response, 'yaksh/courses.html')
diff --git a/yaksh/views.py b/yaksh/views.py
index 336fdee..1d7a8c6 100644
--- a/yaksh/views.py
+++ b/yaksh/views.py
@@ -1072,19 +1072,18 @@ def courses(request):
form = SearchFilterForm()
- if request.method == 'POST':
- course_tags = request.POST.get('search_tags')
- course_status = request.POST.get('search_status')
-
- if course_status == 'select' :
- courses = courses.filter(
- name__contains=course_tags)
- elif course_status == 'active' :
- courses = courses.filter(
- name__contains=course_tags, active=True)
- elif course_status == 'closed':
- courses = courses.filter(
- name__contains=course_tags, active=False)
+ course_tags = request.GET.get('search_tags')
+ course_status = request.GET.get('search_status')
+
+ if course_status == 'select' and course_tags:
+ courses = courses.filter(
+ name__icontains=course_tags)
+ elif course_status == 'active' :
+ courses = courses.filter(
+ name__icontains=course_tags, active=True)
+ elif course_status == 'closed':
+ courses = courses.filter(
+ name__icontains=course_tags, active=False)
paginator = Paginator(courses, 30)
page = request.GET.get('page')