diff options
Diffstat (limited to 'website')
-rw-r--r-- | website/urls.py | 1 | ||||
-rw-r--r-- | website/views.py | 16 |
2 files changed, 17 insertions, 0 deletions
diff --git a/website/urls.py b/website/urls.py index 774acb9..c385ea0 100644 --- a/website/urls.py +++ b/website/urls.py @@ -14,4 +14,5 @@ urlpatterns = patterns('', url(r'^ajax-tutorials/$', 'website.views.ajax_tutorials', name='ajax_tutorials'), url(r'^ajax-duration/$', 'website.views.ajax_duration', name='ajax_duration'), url(r'^ajax-question-update/$', 'website.views.ajax_question_update', name='ajax_question_update'), + url(r'^ajax-similar-questions/$', 'website.views.ajax_similar_questions', name='ajax_similar_questions'), ) diff --git a/website/views.py b/website/views.py index e18a000..538d90e 100644 --- a/website/views.py +++ b/website/views.py @@ -155,3 +155,19 @@ def ajax_question_update(request): question.body = body question.save() return HttpResponse("saved") + +@csrf_exempt +def ajax_similar_questions(request): + if request.method == 'POST': + category = request.POST['category'] + tutorial = request.POST['tutorial'] + minute_range = request.POST['minute_range'] + second_range = request.POST['second_range'] + + # add more filtering when the forum grows + questions = Question.objects.filter(category=category).filter(tutorial=tutorial) + context = { + 'questions': questions + } + return render(request, 'website/templates/ajax-similar-questions.html', context); + |