summaryrefslogtreecommitdiff
path: root/yaksh/forms.py
diff options
context:
space:
mode:
authorPrabhu Ramachandran2017-04-27 18:10:52 +0530
committerGitHub2017-04-27 18:10:52 +0530
commit9d93da09f1483271827099079abf97d84111330f (patch)
treea21f40a84daf2996868b41bb3ea51ad8b755d0e9 /yaksh/forms.py
parent9991300f25ad9d83e0724342c38c7e0f20cee895 (diff)
parentba54ff69f0eb8ff509e4e043c42b933771e205c5 (diff)
downloadonline_test-9d93da09f1483271827099079abf97d84111330f.tar.gz
online_test-9d93da09f1483271827099079abf97d84111330f.tar.bz2
online_test-9d93da09f1483271827099079abf97d84111330f.zip
Merge pull request #272 from ankitjavalkar/course-code
Course code feature
Diffstat (limited to 'yaksh/forms.py')
-rw-r--r--yaksh/forms.py13
1 files changed, 12 insertions, 1 deletions
diff --git a/yaksh/forms.py b/yaksh/forms.py
index f7f7a10..d56fb04 100644
--- a/yaksh/forms.py
+++ b/yaksh/forms.py
@@ -274,10 +274,21 @@ class QuestionFilterForm(forms.Form):
class CourseForm(forms.ModelForm):
""" course form for moderators """
+ 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
+
class Meta:
model = Course
exclude = ['creator', 'requests', 'students', 'rejected',
- 'created_on', 'is_trial', 'teachers']
+ 'created_on', 'is_trial', 'hidden', 'teachers']
class ProfileForm(forms.ModelForm):