summaryrefslogtreecommitdiff
path: root/yaksh/forms.py
diff options
context:
space:
mode:
Diffstat (limited to 'yaksh/forms.py')
-rw-r--r--yaksh/forms.py15
1 files changed, 14 insertions, 1 deletions
diff --git a/yaksh/forms.py b/yaksh/forms.py
index 41c9176..a51e6c2 100644
--- a/yaksh/forms.py
+++ b/yaksh/forms.py
@@ -258,6 +258,7 @@ class QuestionFilterForm(forms.Form):
self.fields['marks'] = forms.FloatField(
widget=forms.Select(choices=points_options)
)
+ self.fields['marks'].required = False
language = forms.CharField(
max_length=8, widget=forms.Select(choices=languages))
question_type = forms.CharField(
@@ -324,7 +325,19 @@ class LessonForm(forms.ModelForm):
class Meta:
model = Lesson
- exclude = ['completed_lessons', 'creator', 'html_data']
+ exclude = ['creator', 'html_data']
+
+ def clean_video_file(self):
+ file = self.cleaned_data.get("video_file")
+ if file:
+ extension = file.name.split(".")[-1]
+ actual_extension = ["mp4", "ogv", "webm"]
+ if extension not in actual_extension:
+ raise forms.ValidationError(
+ "Please upload video files in {0} format".format(
+ ", ".join(actual_extension))
+ )
+ return file
class LessonFileForm(forms.Form):