diff options
author | prathamesh | 2021-03-23 14:57:23 +0530 |
---|---|---|
committer | prathamesh | 2021-03-23 14:57:23 +0530 |
commit | fc070aeab4322cfe34f6074ae1fc07db42be0fe6 (patch) | |
tree | 589bcd30c7d00e5d060e1161fa8583e84f6c3f99 /yaksh/forms.py | |
parent | f5224d8d1866122ad2ecfb3118ffd724c4dd3cf8 (diff) | |
parent | 6fda19daaa06482b8eb52eeb62f9b0a15d0a3da6 (diff) | |
download | online_test-fc070aeab4322cfe34f6074ae1fc07db42be0fe6.tar.gz online_test-fc070aeab4322cfe34f6074ae1fc07db42be0fe6.tar.bz2 online_test-fc070aeab4322cfe34f6074ae1fc07db42be0fe6.zip |
Merge branch 'master' of https://github.com/FOSSEE/online_test into add-test-cases-for-QRcode-based-upload
Diffstat (limited to 'yaksh/forms.py')
-rw-r--r-- | yaksh/forms.py | 33 |
1 files changed, 25 insertions, 8 deletions
diff --git a/yaksh/forms.py b/yaksh/forms.py index d57d388..01e691d 100644 --- a/yaksh/forms.py +++ b/yaksh/forms.py @@ -387,7 +387,7 @@ class QuestionFilterForm(forms.Form): class SearchFilterForm(forms.Form): search_tags = forms.CharField( label='Search Tags', - widget=forms.TextInput(attrs={'placeholder': 'Search', + widget=forms.TextInput(attrs={'placeholder': 'Search by course name', 'class': form_input_class, }), required=False ) @@ -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 |