summaryrefslogtreecommitdiff
path: root/yaksh/forms.py
diff options
context:
space:
mode:
authoradityacp2020-11-18 15:35:03 +0530
committeradityacp2020-11-18 15:35:03 +0530
commita149bf483fe724deb6427cad781279bef28da9fe (patch)
tree39de4e7389d9857df2af885d3e7decbd8eac05e4 /yaksh/forms.py
parenteda9184c193f3a6779b834ace796efbb6dad8b7b (diff)
downloadonline_test-a149bf483fe724deb6427cad781279bef28da9fe.tar.gz
online_test-a149bf483fe724deb6427cad781279bef28da9fe.tar.bz2
online_test-a149bf483fe724deb6427cad781279bef28da9fe.zip
Add dropdown selection for lesson video options
Diffstat (limited to 'yaksh/forms.py')
-rw-r--r--yaksh/forms.py31
1 files changed, 24 insertions, 7 deletions
diff --git a/yaksh/forms.py b/yaksh/forms.py
index d57d388..7a9eb87 100644
--- a/yaksh/forms.py
+++ b/yaksh/forms.py
@@ -515,6 +515,22 @@ class QuestionPaperForm(forms.ModelForm):
class LessonForm(forms.ModelForm):
+ video_options = (
+ ("---", "Select Video Option"), ("youtube", "Youtube"),
+ ("vimeo", "Vimeo"), ("others", "Others")
+ )
+ video_option = forms.ChoiceField(
+ choices=video_options, required=False,
+ help_text='Add videos from youtube, vimeo or other',
+ widget=forms.Select({'class': 'custom-select'}))
+ video_url = forms.CharField(
+ widget=forms.TextInput(
+ {'class': form_input_class,
+ 'placeholder': 'Video ID for Youtube, Vimeo and URL for others'}
+ ),
+ required=False
+ )
+
def __init__(self, *args, **kwargs):
super(LessonForm, self).__init__(*args, **kwargs)
des_msg = "Enter Lesson Description as Markdown text"
@@ -524,13 +540,14 @@ class LessonForm(forms.ModelForm):
self.fields['description'].widget.attrs.update(
{'class': form_input_class, 'placeholder': des_msg}
)
- self.fields['video_path'].widget.attrs.update(
- {'class': form_input_class,
- 'placeholder': dedent("""\
- {'youtube': '', 'vimeo': '', 'others': ''}
- """),
- }
- )
+ self.fields['video_path'].widget = forms.HiddenInput()
+ try:
+ video = literal_eval(self.instance.video_path)
+ key = list(video.keys())[0]
+ self.fields['video_option'].initial = key
+ self.fields['video_url'].initial = video[key]
+ except ValueError:
+ pass
class Meta:
model = Lesson