summaryrefslogtreecommitdiff
path: root/yaksh/forms.py
diff options
context:
space:
mode:
authorKing2016-05-05 18:46:19 +0530
committerKing2016-05-05 18:46:19 +0530
commitd386d24aaa662f91e4314060926dc9bc02426c7d (patch)
tree28e8b0d3e39cf5d9a6ce77b42b712290f1a3baf3 /yaksh/forms.py
parent8841e5ed4f8f79b7067ddb3523f4a3ec50f362b3 (diff)
parente81b13f7d94c0877801726fc85e967f36ba8bd90 (diff)
downloadonline_test-d386d24aaa662f91e4314060926dc9bc02426c7d.tar.gz
online_test-d386d24aaa662f91e4314060926dc9bc02426c7d.tar.bz2
online_test-d386d24aaa662f91e4314060926dc9bc02426c7d.zip
Merge pull request #93 from adityacp/load_dump_questions
Load dump questions
Diffstat (limited to 'yaksh/forms.py')
-rw-r--r--yaksh/forms.py11
1 files changed, 9 insertions, 2 deletions
diff --git a/yaksh/forms.py b/yaksh/forms.py
index 16f82fb..c5bec4c 100644
--- a/yaksh/forms.py
+++ b/yaksh/forms.py
@@ -152,7 +152,7 @@ class QuestionForm(forms.ModelForm):
class Meta:
model = Question
- fields = '__all__'
+ exclude = ['user']
class RandomQuestionForm(forms.Form):
@@ -165,8 +165,9 @@ class RandomQuestionForm(forms.Form):
class QuestionFilterForm(forms.Form):
def __init__(self, *args, **kwargs):
+ user = kwargs.pop("user")
super(QuestionFilterForm, self).__init__(*args, **kwargs)
- questions = Question.objects.all()
+ questions = Question.objects.filter(user_id=user.id)
points_list = questions.values_list('points', flat=True).distinct()
points_options = [('select', 'Select Marks')]
points_options.extend([(point, point) for point in points_list])
@@ -188,6 +189,7 @@ class CourseForm(forms.ModelForm):
model = Course
fields = ['name', 'active', 'enrollment']
+
class ProfileForm(forms.ModelForm):
""" profile form for students and moderators """
@@ -205,3 +207,8 @@ class ProfileForm(forms.ModelForm):
super(ProfileForm, self).__init__(*args, **kwargs)
self.fields['first_name'].initial = user.first_name
self.fields['last_name'].initial = user.last_name
+
+
+class UploadFileForm(forms.Form):
+ file = forms.FileField()
+