From 6e2a0db4d67902cca52277d22dd7a67ebd059268 Mon Sep 17 00:00:00 2001 From: maheshgudi Date: Wed, 7 Sep 2016 16:14:54 +0530 Subject: removed initial form field from QuizForm and minor fixes in add_quiz view function and courses template --- yaksh/forms.py | 5 ++--- yaksh/templates/yaksh/courses.html | 3 ++- yaksh/views.py | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/yaksh/forms.py b/yaksh/forms.py index 62179d5..23131b7 100644 --- a/yaksh/forms.py +++ b/yaksh/forms.py @@ -156,12 +156,11 @@ class QuizForm(forms.ModelForm): course_id = kwargs.pop('course') super(QuizForm, self).__init__(*args, **kwargs) self.fields['prerequisite'] = forms.ModelChoiceField( - queryset=Quiz.objects.filter(course__creator=user, + queryset=Quiz.objects.filter(course__id=course_id, is_trial=False)) self.fields['prerequisite'].required = False self.fields['course'] = forms.ModelChoiceField( - queryset=Course.objects.filter(id=course_id)) - self.fields['course'].initial = Course.objects.get(id=course_id) + queryset=Course.objects.filter(id=course_id), empty_label=None) class Meta: model = Quiz diff --git a/yaksh/templates/yaksh/courses.html b/yaksh/templates/yaksh/courses.html index ba7d09f..109b996 100644 --- a/yaksh/templates/yaksh/courses.html +++ b/yaksh/templates/yaksh/courses.html @@ -147,7 +147,8 @@

{% endfor %} {% else %} -

No new Courses allotted

+

No new Courses allotted

+

{% endif %}
diff --git a/yaksh/views.py b/yaksh/views.py index dcf6133..fa4dac6 100644 --- a/yaksh/views.py +++ b/yaksh/views.py @@ -250,7 +250,7 @@ def add_quiz(request, course_id, quiz_id=None): """To add a new quiz in the database. Create a new quiz and store it.""" user = request.user - course = Course.objects.get(id=course_id) + course = get_object_or_404(Course, pk=course_id) ci = RequestContext(request) if not is_moderator(user) or (user != course.creator and user not in course.teachers.all()): raise Http404('You are not allowed to view this page!') -- cgit