summaryrefslogtreecommitdiff
path: root/yaksh/forms.py
diff options
context:
space:
mode:
authoradityacp2020-01-24 10:03:39 +0530
committeradityacp2020-01-24 10:03:39 +0530
commit547575e98d119a00472efe3d70693ed972468031 (patch)
tree2fc350741ebf7d78ec62eb2b41f262d53514e612 /yaksh/forms.py
parentebbb1b4d3dcec668b901200de7b31253162da80c (diff)
parent7edfc63ab89d65337e17e8a79e8114a74b2146e3 (diff)
downloadonline_test-547575e98d119a00472efe3d70693ed972468031.tar.gz
online_test-547575e98d119a00472efe3d70693ed972468031.tar.bz2
online_test-547575e98d119a00472efe3d70693ed972468031.zip
Resolve conflicts in grade user, custom filters etc
Diffstat (limited to 'yaksh/forms.py')
-rw-r--r--yaksh/forms.py24
1 files changed, 17 insertions, 7 deletions
diff --git a/yaksh/forms.py b/yaksh/forms.py
index 414bff5..d82cd55 100644
--- a/yaksh/forms.py
+++ b/yaksh/forms.py
@@ -3,6 +3,7 @@ from yaksh.models import (
get_model_class, Profile, Quiz, Question, Course, QuestionPaper, Lesson,
LearningModule
)
+from grades.models import GradingSystem
from django.contrib.auth import authenticate
from django.contrib.auth.models import User
from django.conf import settings
@@ -345,6 +346,13 @@ class QuestionFilterForm(forms.Form):
class CourseForm(forms.ModelForm):
""" course form for moderators """
+ class Meta:
+ model = Course
+ fields = [
+ 'name', 'enrollment', 'active', 'code', 'instructions',
+ 'start_enroll_time', 'end_enroll_time', 'grading_system',
+ 'view_grade'
+ ]
def __init__(self, *args, **kwargs):
super(CourseForm, self).__init__(*args, **kwargs)
@@ -381,13 +389,15 @@ class CourseForm(forms.ModelForm):
instance.save()
return instance
- class Meta:
- model = Course
- fields = [
- 'name', 'enrollment', 'active', 'code', 'instructions',
- 'start_enroll_time', 'end_enroll_time', 'grading_system',
- 'view_grade'
- ]
+ 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:
+ grading_choices = GradingSystem.objects.filter(
+ creator=user
+ )
+ self.fields['grading_system'].queryset = grading_choices
class ProfileForm(forms.ModelForm):