diff options
author | adityacp | 2018-06-26 13:13:22 +0530 |
---|---|---|
committer | adityacp | 2018-06-26 13:13:22 +0530 |
commit | 20b692ea468a280e3edb4a9e7f97543b5499025d (patch) | |
tree | aff5b76b2bb3f7b3507e9fe4841762310939273d /yaksh/forms.py | |
parent | 4eb754c2e71922819de7390d1b4993a21763de3e (diff) | |
download | online_test-20b692ea468a280e3edb4a9e7f97543b5499025d.tar.gz online_test-20b692ea468a280e3edb4a9e7f97543b5499025d.tar.bz2 online_test-20b692ea468a280e3edb4a9e7f97543b5499025d.zip |
Changes in views, models, forms, urls, file_utils
- Add new view function to download course content
- Add new attribute to Lesson model
- Add new model methods to add course, module and lesson content
- Add validation in forms to check for lesson video file format
- Add functions in file_utils to add static files and templates to the zip file
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 41c9176..66076b1 100644 --- a/yaksh/forms.py +++ b/yaksh/forms.py @@ -324,7 +324,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"] + 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): |