diff options
Diffstat (limited to 'yaksh/forms.py')
-rw-r--r-- | yaksh/forms.py | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/yaksh/forms.py b/yaksh/forms.py index 99e8dbe..a51e6c2 100644 --- a/yaksh/forms.py +++ b/yaksh/forms.py @@ -325,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): |