diff options
author | ankitjavalkar | 2017-04-05 18:50:00 +0530 |
---|---|---|
committer | ankitjavalkar | 2017-04-27 17:42:25 +0530 |
commit | 290b71a311ad245b996f38bc7da4080a07493958 (patch) | |
tree | 3c1a35f9de2e8c0bd9d7662656b8112a840fd6ca /yaksh/forms.py | |
parent | 9991300f25ad9d83e0724342c38c7e0f20cee895 (diff) | |
download | online_test-290b71a311ad245b996f38bc7da4080a07493958.tar.gz online_test-290b71a311ad245b996f38bc7da4080a07493958.tar.bz2 online_test-290b71a311ad245b996f38bc7da4080a07493958.zip |
Add course_code field allows access only to users with relevant course code string
Diffstat (limited to 'yaksh/forms.py')
-rw-r--r-- | yaksh/forms.py | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/yaksh/forms.py b/yaksh/forms.py index f7f7a10..1306e7d 100644 --- a/yaksh/forms.py +++ b/yaksh/forms.py @@ -274,6 +274,17 @@ 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', |