From 290b71a311ad245b996f38bc7da4080a07493958 Mon Sep 17 00:00:00 2001 From: ankitjavalkar Date: Wed, 5 Apr 2017 18:50:00 +0530 Subject: Add course_code field allows access only to users with relevant course code string --- yaksh/forms.py | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'yaksh/forms.py') 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', -- cgit From 37a4f9704bcd7e3590b61ff4668bc547a232ed7f Mon Sep 17 00:00:00 2001 From: ankitjavalkar Date: Wed, 19 Apr 2017 10:43:25 +0530 Subject: Hide field in CourseForm --- yaksh/forms.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'yaksh/forms.py') diff --git a/yaksh/forms.py b/yaksh/forms.py index 1306e7d..d56fb04 100644 --- a/yaksh/forms.py +++ b/yaksh/forms.py @@ -288,7 +288,7 @@ class CourseForm(forms.ModelForm): class Meta: model = Course exclude = ['creator', 'requests', 'students', 'rejected', - 'created_on', 'is_trial', 'teachers'] + 'created_on', 'is_trial', 'hidden', 'teachers'] class ProfileForm(forms.ModelForm): -- cgit