From eaf4873ff71eb3655a82f24d05e00881040a4326 Mon Sep 17 00:00:00 2001 From: adityacp Date: Tue, 28 Jan 2020 18:18:07 +0530 Subject: Change in views, forms, templates, static - Revamp UI in student dashboard - Fix course form to get bootstrap form class - Add custom css for sidebar in course module page for student - Use django url pattern --- yaksh/forms.py | 27 ++++++++++++--------------- 1 file changed, 12 insertions(+), 15 deletions(-) (limited to 'yaksh/forms.py') diff --git a/yaksh/forms.py b/yaksh/forms.py index d82cd55..79342da 100644 --- a/yaksh/forms.py +++ b/yaksh/forms.py @@ -354,7 +354,18 @@ class CourseForm(forms.ModelForm): 'view_grade' ] - def __init__(self, *args, **kwargs): + def save(self, commit=True, *args, **kwargs): + instance = super(CourseForm, self).save(commit=False) + if instance.code: + instance.hidden = True + else: + instance.hidden = False + + if commit: + instance.save() + return instance + + def __init__(self, user, *args, **kwargs): super(CourseForm, self).__init__(*args, **kwargs) self.fields['name'].widget.attrs.update( {'class': form_input_class, 'placeholder': 'Course Name'} @@ -377,20 +388,6 @@ class CourseForm(forms.ModelForm): self.fields['grading_system'].widget.attrs.update( {'class': 'custom-select'} ) - - def save(self, commit=True, *args, **kwargs): - instance = super(CourseForm, self).save(commit=False) - if instance.code: - instance.hidden = True - else: - instance.hidden = False - - if commit: - instance.save() - return instance - - def __init__(self, user, *args, **kwargs): - super(CourseForm, self).__init__(*args, **kwargs) if self.instance.id and self.instance.teachers.filter(id=user.id).exists(): self.fields['grading_system'].widget.attrs['disabled'] = True else: -- cgit