summaryrefslogtreecommitdiff
path: root/yaksh/views.py
diff options
context:
space:
mode:
authorCruiseDevice2019-12-23 13:06:48 +0530
committerCruiseDevice2020-01-02 16:20:31 +0530
commit925d616c4137f014f2f55a979b2350ef0409a5b9 (patch)
treed1747de34407fde93e108810a5feeee242a8e341 /yaksh/views.py
parent75e8fb06b42420f21c8571341ef8300a102cd2c7 (diff)
downloadonline_test-925d616c4137f014f2f55a979b2350ef0409a5b9.tar.gz
online_test-925d616c4137f014f2f55a979b2350ef0409a5b9.tar.bz2
online_test-925d616c4137f014f2f55a979b2350ef0409a5b9.zip
Resolve comments
- Fix PEP8 - Change the url as per django urlpattern - Replace all the buttons by <a> tag - Use get_queryset() for filtering data for pagination - Make buttons large - Add Pagination in ajax_question_filter.html - Hide Pagination when there is no question object
Diffstat (limited to 'yaksh/views.py')
-rw-r--r--yaksh/views.py20
1 files changed, 16 insertions, 4 deletions
diff --git a/yaksh/views.py b/yaksh/views.py
index d82d4e0..f5a4b82 100644
--- a/yaksh/views.py
+++ b/yaksh/views.py
@@ -1324,10 +1324,21 @@ def ajax_questions_filter(request):
if language:
filter_dict['language'] = str(language)
- questions = Question.objects.filter(**filter_dict)
-
+ questions = Question.objects.get_queryset().filter(
+ **filter_dict).order_by('id')
+ paginator = Paginator(questions, 10)
+ page = request.GET.get('page')
+ try:
+ questions = paginator.page(page)
+ except PageNotAnInteger:
+ questions = paginator.page(1)
+ except EmptyPage:
+ questions = paginator.page(paginator.num_pages)
return my_render_to_response(
- request, 'yaksh/ajax_question_filter.html', {'questions': questions}
+ request, 'yaksh/ajax_question_filter.html', {
+ 'questions': questions,
+ 'objects': questions
+ }
)
@@ -1492,7 +1503,8 @@ def show_all_questions(request):
if not is_moderator(user):
raise Http404("You are not allowed to view this page !")
- questions = Question.objects.filter(user_id=user.id, active=True)
+ questions = Question.objects.get_queryset().filter(
+ user_id=user.id, active=True).order_by('id')
form = QuestionFilterForm(user=user)
user_tags = questions.values_list('tags', flat=True).distinct()
all_tags = Tag.objects.filter(id__in=user_tags)