summaryrefslogtreecommitdiff
path: root/yaksh/forms.py
diff options
context:
space:
mode:
authoradityacp2020-01-28 18:18:07 +0530
committeradityacp2020-01-28 18:18:07 +0530
commiteaf4873ff71eb3655a82f24d05e00881040a4326 (patch)
treefd4f7b735da95e9ce64dca83101ba1a80cde5270 /yaksh/forms.py
parent547575e98d119a00472efe3d70693ed972468031 (diff)
downloadonline_test-eaf4873ff71eb3655a82f24d05e00881040a4326.tar.gz
online_test-eaf4873ff71eb3655a82f24d05e00881040a4326.tar.bz2
online_test-eaf4873ff71eb3655a82f24d05e00881040a4326.zip
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
Diffstat (limited to 'yaksh/forms.py')
-rw-r--r--yaksh/forms.py27
1 files changed, 12 insertions, 15 deletions
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: