diff options
author | Prabhu Ramachandran | 2016-05-10 20:09:08 +0530 |
---|---|---|
committer | Prabhu Ramachandran | 2016-05-10 20:09:08 +0530 |
commit | 5c74697b00ea08a2b78615637d8b322410fca4b0 (patch) | |
tree | d5b937e90bc7d3051b9c9128c4e1560b09db1c2c /yaksh/forms.py | |
parent | d386d24aaa662f91e4314060926dc9bc02426c7d (diff) | |
parent | c384c60c6d7fb5d30f3f929c518e0b41e084c4c4 (diff) | |
download | online_test-5c74697b00ea08a2b78615637d8b322410fca4b0.tar.gz online_test-5c74697b00ea08a2b78615637d8b322410fca4b0.tar.bz2 online_test-5c74697b00ea08a2b78615637d8b322410fca4b0.zip |
Merge pull request #96 from ankitjavalkar/code-eval-refactor-clean2
Code evaluator refactor
Diffstat (limited to 'yaksh/forms.py')
-rw-r--r-- | yaksh/forms.py | 22 |
1 files changed, 17 insertions, 5 deletions
diff --git a/yaksh/forms.py b/yaksh/forms.py index c5bec4c..808262b 100644 --- a/yaksh/forms.py +++ b/yaksh/forms.py @@ -1,8 +1,10 @@ from django import forms -from yaksh.models import Profile, Quiz, Question, TestCase, Course +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 +from django.contrib.contenttypes.models import ContentType + from taggit.managers import TaggableManager from taggit.forms import TagField from django.forms.models import inlineformset_factory @@ -28,6 +30,12 @@ question_types = ( ("upload", "Assignment Upload"), ) +test_case_types = ( + ("standardtestcase", "Standard Testcase"), + ("stdoutbasedtestcase", "Stdout Based Testcase"), + ("mcqtestcase", "MCQ Testcase"), + ) + UNAME_CHARS = letters + "._" + digits PWD_CHARS = letters + punctuation + digits @@ -35,6 +43,14 @@ attempts = [(i, i) for i in range(1, 6)] attempts.append((-1, 'Infinite')) days_between_attempts = ((j, j) for j in range(401)) +def get_object_form(model, exclude_fields=None): + model_class = get_model_class(model) + class _ObjectForm(forms.ModelForm): + class Meta: + model = model_class + exclude = exclude_fields + return _ObjectForm + class UserRegisterForm(forms.Form): """A Class to create new form for User's Registration. @@ -180,10 +196,6 @@ class QuestionFilterForm(forms.Form): (choices=question_types)) -TestCaseFormSet = inlineformset_factory(Question, TestCase, fields='__all__', - can_order=False, can_delete=False, extra=1) - - class CourseForm(forms.ModelForm): class Meta: model = Course |