From 75e8fb06b42420f21c8571341ef8300a102cd2c7 Mon Sep 17 00:00:00 2001 From: CruiseDevice Date: Thu, 2 Jan 2020 16:18:59 +0530 Subject: Resolve conflicts --- yaksh/forms.py | 11 +- yaksh/static/yaksh/css/custom.css | 9 ++ yaksh/templates/base.html | 3 +- yaksh/templates/yaksh/showquestions.html | 268 ++++++++++++++----------------- yaksh/views.py | 9 ++ 5 files changed, 146 insertions(+), 154 deletions(-) diff --git a/yaksh/forms.py b/yaksh/forms.py index 8cc3d0a..4a90ef7 100644 --- a/yaksh/forms.py +++ b/yaksh/forms.py @@ -295,13 +295,16 @@ class QuestionFilterForm(forms.Form): points_options = [(None, 'Select Marks')] points_options.extend([(point, point) for point in points_list]) self.fields['marks'] = forms.FloatField( - widget=forms.Select(choices=points_options) + widget=forms.Select(choices=points_options, + attrs={'class': 'custom-select'}) ) self.fields['marks'].required = False language = forms.CharField( - max_length=8, widget=forms.Select(choices=languages)) + max_length=8, widget=forms.Select(choices=languages, + attrs={'class': 'custom-select'})) question_type = forms.CharField( - max_length=8, widget=forms.Select(choices=question_types) + max_length=8, widget=forms.Select(choices=question_types, + attrs={'class': 'custom-select'}) ) @@ -396,7 +399,7 @@ class ProfileForm(forms.ModelForm): ) class UploadFileForm(forms.Form): - file = forms.FileField() + file = forms.FileField(widget=forms.FileInput(attrs={'class':'upload'})) class QuestionPaperForm(forms.ModelForm): diff --git a/yaksh/static/yaksh/css/custom.css b/yaksh/static/yaksh/css/custom.css index d0d5c82..55d5d6d 100644 --- a/yaksh/static/yaksh/css/custom.css +++ b/yaksh/static/yaksh/css/custom.css @@ -24,6 +24,15 @@ body, .dropdown-menu { font-size: 1.25rem; } +.base-content { + padding-top: 5em; + padding-bottom: 5em; +} + #login-btn, #signup-btn, #forgot-btn{ width: 75%; } + +.dropdown { + display: flex; +} diff --git a/yaksh/templates/base.html b/yaksh/templates/base.html index 9021e3d..0cfe8a3 100644 --- a/yaksh/templates/base.html +++ b/yaksh/templates/base.html @@ -43,7 +43,6 @@ {% block script %} {% endblock %} - @@ -58,7 +57,7 @@ {% block nav %} {% endblock %} -
+

{% block pagetitle %}{% endblock pagetitle %}

diff --git a/yaksh/templates/yaksh/showquestions.html b/yaksh/templates/yaksh/showquestions.html index e146878..31312e2 100644 --- a/yaksh/templates/yaksh/showquestions.html +++ b/yaksh/templates/yaksh/showquestions.html @@ -1,39 +1,38 @@ {% extends "manage.html" %} +{% load staticfiles %} {% block title %} Questions {% endblock %} {% block pagetitle %} Questions {% endblock pagetitle %} {% block script %} - - - + + + {% endblock %} {% block content %} -
- - - - -
- -
- -
- - +
+

Or

- {% csrf_token %} - {{ upload_form.as_p }} -
-

And

- + {% csrf_token %} +
+
+
+ {{ upload_form.as_p }} +
+
+
+

And

+
-
- +
+ - -
-
- {% csrf_token %} - {% if message %} - {%if message == "Questions Uploaded Successfully"%} -
- × - {{ message }} -
- {%else %} -
- × + +
+ + {% csrf_token %} + {% if message %} + {%if message == "Questions Uploaded Successfully"%} +
+ × {{ message }} -
- {% endif %} - {% endif %} - {% if msg %} -
+
+ {%else %} +
× - {{ msg }} + {{ message }}
{% endif %} -

- -
-
+ {% endif %} + {% if msg %} +
+ × + {{ msg }} +
+ {% endif %} + +
+
+
-
-

Filters Questions:

-
- {{ form.question_type }} -
-
- {{ form.language }} -
-
- {{ form.marks }} -
-

- +
+

Filters Questions:

+

Or Search using Tags:

{% csrf_token %} -
-
-
-
-
- Search Questions -
- - - - -
+
+
+
+
+
+ Search Questions +
+ + + +
- -
- {% if all_tags %} {% for tag in all_tags %} @@ -134,84 +128,62 @@ {% else %} {% endif %} - -
+
-
-

+
+
+
-
-
- -
+
+
+
{% if questions %} -
-
Select All
-
- +
+
+
Select All
+
+
- - - - - + + + + + {% for question in questions %} - - - - - + + + + + {% endfor %} -
Select Summary Language Type Marks Select Summary Language Type Marks
- - {{question.summary|capfirst}}{{question.language|capfirst}}{{question.type|capfirst}}{{question.points}} + + {{question.summary|capfirst}}{{question.language|capfirst}}{{question.type|capfirst}}{{question.points}}
-
-
+ +
+
{% endif %} -
-
-
-    - {% if questions %} -    -    - {% endif %} - -
-
-
- +
+ {% include "yaksh/paginator.html" %} +
+ + {% if questions %} + + + {% endif %} + +
+
-
+ +
{% endblock %} -{% block footer %} - - - -{% endblock %} \ No newline at end of file diff --git a/yaksh/views.py b/yaksh/views.py index 7e9b706..d82d4e0 100644 --- a/yaksh/views.py +++ b/yaksh/views.py @@ -1497,7 +1497,16 @@ def show_all_questions(request): 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 -- cgit From 925d616c4137f014f2f55a979b2350ef0409a5b9 Mon Sep 17 00:00:00 2001 From: CruiseDevice Date: Mon, 23 Dec 2019 13:06:48 +0530 Subject: Resolve comments - Fix PEP8 - Change the url as per django urlpattern - Replace all the buttons by 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 --- yaksh/forms.py | 2 +- yaksh/templates/yaksh/ajax_question_filter.html | 5 ++++- yaksh/templates/yaksh/showquestions.html | 30 +++++++++++++------------ yaksh/views.py | 20 +++++++++++++---- 4 files changed, 37 insertions(+), 20 deletions(-) diff --git a/yaksh/forms.py b/yaksh/forms.py index 4a90ef7..ffb15a6 100644 --- a/yaksh/forms.py +++ b/yaksh/forms.py @@ -399,7 +399,7 @@ class ProfileForm(forms.ModelForm): ) class UploadFileForm(forms.Form): - file = forms.FileField(widget=forms.FileInput(attrs={'class':'upload'})) + file = forms.FileField(widget=forms.FileInput(attrs={'class': 'upload'})) class QuestionPaperForm(forms.ModelForm): diff --git a/yaksh/templates/yaksh/ajax_question_filter.html b/yaksh/templates/yaksh/ajax_question_filter.html index ea0d0b5..7dba6df 100644 --- a/yaksh/templates/yaksh/ajax_question_filter.html +++ b/yaksh/templates/yaksh/ajax_question_filter.html @@ -16,6 +16,8 @@ }); {% if questions %} + {% include "yaksh/paginator.html" %} +
Select All
@@ -36,7 +38,7 @@ -
{{question.summary|capfirst}} + {{question.summary|capfirst}} {{question.language|capfirst}} {{question.type|capfirst}} {{question.points}} @@ -45,5 +47,6 @@ + {% include "yaksh/paginator.html" %} {% endif %}
diff --git a/yaksh/templates/yaksh/showquestions.html b/yaksh/templates/yaksh/showquestions.html index 31312e2..3353e4a 100644 --- a/yaksh/templates/yaksh/showquestions.html +++ b/yaksh/templates/yaksh/showquestions.html @@ -46,7 +46,7 @@

-
Download Template
+
Download Template

Or

@@ -59,7 +59,7 @@

And

- + Upload File @@ -72,19 +72,19 @@ {% if message %} {%if message == "Questions Uploaded Successfully"%}
- × + {{ message }}
{%else %}
- × + {{ message }}
{% endif %} {% endif %} {% if msg %}
- × + {{ msg }}
{% endif %} @@ -112,7 +112,7 @@ - + @@ -133,13 +133,14 @@
- + + Clear Filters
{% if questions %}
+ {% include "yaksh/paginator.html" %}
Select All
@@ -159,7 +160,7 @@ - {{question.summary|capfirst}} + {{question.summary|capfirst}} {{question.language|capfirst}} {{question.type|capfirst}} {{question.points}} @@ -169,16 +170,17 @@
+ {% include "yaksh/paginator.html" %} {% endif %}
- {% include "yaksh/paginator.html" %}
- + Add Question + {% if questions %} - - + Download Selected + Test Selected {% endif %} - + Delete Selected
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) -- cgit From 122e841eecd8d322eba1c24dadde392617a5c231 Mon Sep 17 00:00:00 2001 From: CruiseDevice Date: Thu, 26 Dec 2019 15:10:29 +0530 Subject: Resolve comments --- yaksh/templates/yaksh/showquestions.html | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/yaksh/templates/yaksh/showquestions.html b/yaksh/templates/yaksh/showquestions.html index 3353e4a..d0c33dd 100644 --- a/yaksh/templates/yaksh/showquestions.html +++ b/yaksh/templates/yaksh/showquestions.html @@ -59,7 +59,7 @@

And

- Upload File + @@ -133,13 +133,14 @@
- + Clear Filters
{% if questions %}
+
{% include "yaksh/paginator.html" %}
Select All
@@ -174,13 +175,13 @@ {% endif %}
- Add Question + Add Question {% if questions %} - Download Selected - Test Selected + + {% endif %} - Delete Selected +
-- cgit From e7f83b0f9e098ffb4066fce50f1d60972b5edfcb Mon Sep 17 00:00:00 2001 From: CruiseDevice Date: Thu, 2 Jan 2020 16:16:29 +0530 Subject: set template debug to True to avoid restarting django server --- online_test/settings.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/online_test/settings.py b/online_test/settings.py index 6838865..6ff31f8 100644 --- a/online_test/settings.py +++ b/online_test/settings.py @@ -165,7 +165,7 @@ TEMPLATES = [ 'social_django.context_processors.login_redirect', 'django.contrib.messages.context_processors.messages', ], - 'debug': False, + 'debug': True, # make this False in production } }, ] -- cgit