summaryrefslogtreecommitdiff
path: root/yaksh/views.py
diff options
context:
space:
mode:
authorAkash Chavan2020-01-02 16:24:00 +0530
committerGitHub2020-01-02 16:24:00 +0530
commit293e95bd0920d2f06058cf3ee4c0be3c2b3cf905 (patch)
tree8cfc13994d38714df26478c85a34ec70741bfab3 /yaksh/views.py
parenteb05d4b0bc3fd0e2ce5160f30251bd9b939ccef6 (diff)
parente7f83b0f9e098ffb4066fce50f1d60972b5edfcb (diff)
downloadonline_test-293e95bd0920d2f06058cf3ee4c0be3c2b3cf905.tar.gz
online_test-293e95bd0920d2f06058cf3ee4c0be3c2b3cf905.tar.bz2
online_test-293e95bd0920d2f06058cf3ee4c0be3c2b3cf905.zip
Merge pull request #636 from CruiseDevice/revamp_ui
Fix UI, add Pagination to showquestions.html
Diffstat (limited to 'yaksh/views.py')
-rw-r--r--yaksh/views.py29
1 files changed, 25 insertions, 4 deletions
diff --git a/yaksh/views.py b/yaksh/views.py
index 7e9b706..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,12 +1503,22 @@ 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)
upload_form = UploadFileForm()
+ 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)
context['questions'] = questions
+ context['objects'] = questions
context['all_tags'] = all_tags
context['papers'] = []
context['question'] = None