diff options
Diffstat (limited to 'yaksh')
-rw-r--r-- | yaksh/forms.py | 7 | ||||
-rw-r--r-- | yaksh/models.py | 5 |
2 files changed, 9 insertions, 3 deletions
diff --git a/yaksh/forms.py b/yaksh/forms.py index 9ffef5e..ddb1819 100644 --- a/yaksh/forms.py +++ b/yaksh/forms.py @@ -1,5 +1,5 @@ from django import forms -from yaksh.models import Profile, Quiz, Question, TestCase, Course, StandardTestCase, StdoutBasedTestCase +from yaksh.models import get_model_class, Profile, Quiz, Question, TestCase, Course, StandardTestCase, StdoutBasedTestCase from django.contrib.auth import authenticate from django.contrib.auth.models import User @@ -44,9 +44,10 @@ attempts.append((-1, 'Infinite')) days_between_attempts = ((j, j) for j in range(401)) def get_object_form(model, exclude_fields=None): - ctype = ContentType.objects.get(app_label="yaksh", model=model) + # ctype = ContentType.objects.get(app_label="yaksh", model=model) # ctype = ContentType.objects.get(pk=type_id) - model_class = ctype.model_class() + # model_class = ctype.model_class() + model_class = get_model_class(model) class _ObjectForm(forms.ModelForm): # def __init__(self, *args, **kwargs): # if "question" in kwargs: diff --git a/yaksh/models.py b/yaksh/models.py index b1a53f0..db4b7a8 100644 --- a/yaksh/models.py +++ b/yaksh/models.py @@ -50,6 +50,11 @@ test_status = ( def get_assignment_dir(instance, filename): return '%s/%s' % (instance.user.roll_number, instance.assignmentQuestion.id) +def get_model_class(model): + ctype = ContentType.objects.get(app_label="yaksh", model=model) + model_class = ctype.model_class() + + ############################################################################### class Course(models.Model): |