testappproj/testapp/forms.py
author amit@thunder
Mon, 31 May 2010 19:18:57 +0530
changeset 2 654c583fd78e
parent 1 0eda880b3d25
child 3 34d0c21e3352
permissions -rw-r--r--
Made some changes and templates
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
0
0b061d58aea3 First commit to Fossee of testapp has the basic Pykata framework on django with some specific changes to Problems model and some views to suit an exam like system
amit@thunder
parents:
diff changeset
     1
from django import forms
0b061d58aea3 First commit to Fossee of testapp has the basic Pykata framework on django with some specific changes to Problems model and some views to suit an exam like system
amit@thunder
parents:
diff changeset
     2
from registration.forms import RegistrationForm
0b061d58aea3 First commit to Fossee of testapp has the basic Pykata framework on django with some specific changes to Problems model and some views to suit an exam like system
amit@thunder
parents:
diff changeset
     3
from django.utils.translation import ugettext_lazy as _
0b061d58aea3 First commit to Fossee of testapp has the basic Pykata framework on django with some specific changes to Problems model and some views to suit an exam like system
amit@thunder
parents:
diff changeset
     4
from testapp.models import Test_User
0b061d58aea3 First commit to Fossee of testapp has the basic Pykata framework on django with some specific changes to Problems model and some views to suit an exam like system
amit@thunder
parents:
diff changeset
     5
from registration.models import RegistrationProfile
0b061d58aea3 First commit to Fossee of testapp has the basic Pykata framework on django with some specific changes to Problems model and some views to suit an exam like system
amit@thunder
parents:
diff changeset
     6
#from google.appengine.ext.db import djangoforms
0b061d58aea3 First commit to Fossee of testapp has the basic Pykata framework on django with some specific changes to Problems model and some views to suit an exam like system
amit@thunder
parents:
diff changeset
     7
import models
0b061d58aea3 First commit to Fossee of testapp has the basic Pykata framework on django with some specific changes to Problems model and some views to suit an exam like system
amit@thunder
parents:
diff changeset
     8
0b061d58aea3 First commit to Fossee of testapp has the basic Pykata framework on django with some specific changes to Problems model and some views to suit an exam like system
amit@thunder
parents:
diff changeset
     9
0b061d58aea3 First commit to Fossee of testapp has the basic Pykata framework on django with some specific changes to Problems model and some views to suit an exam like system
amit@thunder
parents:
diff changeset
    10
attrs_dict = { 'class': 'required' }
0b061d58aea3 First commit to Fossee of testapp has the basic Pykata framework on django with some specific changes to Problems model and some views to suit an exam like system
amit@thunder
parents:
diff changeset
    11
0b061d58aea3 First commit to Fossee of testapp has the basic Pykata framework on django with some specific changes to Problems model and some views to suit an exam like system
amit@thunder
parents:
diff changeset
    12
PROBLEM_CHOICES=(
0b061d58aea3 First commit to Fossee of testapp has the basic Pykata framework on django with some specific changes to Problems model and some views to suit an exam like system
amit@thunder
parents:
diff changeset
    13
    ('P', 'Plotting'),
0b061d58aea3 First commit to Fossee of testapp has the basic Pykata framework on django with some specific changes to Problems model and some views to suit an exam like system
amit@thunder
parents:
diff changeset
    14
    ('S', 'Scripting'),
0b061d58aea3 First commit to Fossee of testapp has the basic Pykata framework on django with some specific changes to Problems model and some views to suit an exam like system
amit@thunder
parents:
diff changeset
    15
)
0b061d58aea3 First commit to Fossee of testapp has the basic Pykata framework on django with some specific changes to Problems model and some views to suit an exam like system
amit@thunder
parents:
diff changeset
    16
0b061d58aea3 First commit to Fossee of testapp has the basic Pykata framework on django with some specific changes to Problems model and some views to suit an exam like system
amit@thunder
parents:
diff changeset
    17
SESSION_CHOICES=(
0b061d58aea3 First commit to Fossee of testapp has the basic Pykata framework on django with some specific changes to Problems model and some views to suit an exam like system
amit@thunder
parents:
diff changeset
    18
  ('A','DAY 1 SESSION 1'),
0b061d58aea3 First commit to Fossee of testapp has the basic Pykata framework on django with some specific changes to Problems model and some views to suit an exam like system
amit@thunder
parents:
diff changeset
    19
  ('B','DAY 1 SESSION 2'),
0b061d58aea3 First commit to Fossee of testapp has the basic Pykata framework on django with some specific changes to Problems model and some views to suit an exam like system
amit@thunder
parents:
diff changeset
    20
  ('C','DAY 1 SESSION 3'),
0b061d58aea3 First commit to Fossee of testapp has the basic Pykata framework on django with some specific changes to Problems model and some views to suit an exam like system
amit@thunder
parents:
diff changeset
    21
  ('D','DAY 1 SESSION 4'),
0b061d58aea3 First commit to Fossee of testapp has the basic Pykata framework on django with some specific changes to Problems model and some views to suit an exam like system
amit@thunder
parents:
diff changeset
    22
  ('E','DAY 2 SESSION 1'),
0b061d58aea3 First commit to Fossee of testapp has the basic Pykata framework on django with some specific changes to Problems model and some views to suit an exam like system
amit@thunder
parents:
diff changeset
    23
  ('F','DAY 2 SESSION 2'),
0b061d58aea3 First commit to Fossee of testapp has the basic Pykata framework on django with some specific changes to Problems model and some views to suit an exam like system
amit@thunder
parents:
diff changeset
    24
  ('G','DAY 2 SESSION 3'),
0b061d58aea3 First commit to Fossee of testapp has the basic Pykata framework on django with some specific changes to Problems model and some views to suit an exam like system
amit@thunder
parents:
diff changeset
    25
  ('H','DAY 2 SESSION 4'),
0b061d58aea3 First commit to Fossee of testapp has the basic Pykata framework on django with some specific changes to Problems model and some views to suit an exam like system
amit@thunder
parents:
diff changeset
    26
  )
0b061d58aea3 First commit to Fossee of testapp has the basic Pykata framework on django with some specific changes to Problems model and some views to suit an exam like system
amit@thunder
parents:
diff changeset
    27
0b061d58aea3 First commit to Fossee of testapp has the basic Pykata framework on django with some specific changes to Problems model and some views to suit an exam like system
amit@thunder
parents:
diff changeset
    28
0b061d58aea3 First commit to Fossee of testapp has the basic Pykata framework on django with some specific changes to Problems model and some views to suit an exam like system
amit@thunder
parents:
diff changeset
    29
class ProblemForm(forms.Form):
0b061d58aea3 First commit to Fossee of testapp has the basic Pykata framework on django with some specific changes to Problems model and some views to suit an exam like system
amit@thunder
parents:
diff changeset
    30
  Description = forms.CharField(widget=forms.Textarea(attrs={'rows': '10', 'cols': '80'}),required=True,help_text="To be used as the question")
0b061d58aea3 First commit to Fossee of testapp has the basic Pykata framework on django with some specific changes to Problems model and some views to suit an exam like system
amit@thunder
parents:
diff changeset
    31
  Problem_type = forms.ChoiceField(choices=PROBLEM_CHOICES,required=True)
2
654c583fd78e Made some changes and templates
amit@thunder
parents: 1
diff changeset
    32
  Solution = forms.CharField(widget=forms.Textarea(attrs={'rows': '10', 'cols': '80'}),help_text="comma seperated in case of multiple solutions",required=False)
0
0b061d58aea3 First commit to Fossee of testapp has the basic Pykata framework on django with some specific changes to Problems model and some views to suit an exam like system
amit@thunder
parents:
diff changeset
    33
  Solution_Image = forms.ImageField(required=False)
0b061d58aea3 First commit to Fossee of testapp has the basic Pykata framework on django with some specific changes to Problems model and some views to suit an exam like system
amit@thunder
parents:
diff changeset
    34
  Session = forms.ChoiceField(choices=SESSION_CHOICES, required=True)
1
0eda880b3d25 started the basic framework evaluating results
amit@thunder
parents: 0
diff changeset
    35
  Credit=forms.IntegerField(required=True)
0
0b061d58aea3 First commit to Fossee of testapp has the basic Pykata framework on django with some specific changes to Problems model and some views to suit an exam like system
amit@thunder
parents:
diff changeset
    36
0b061d58aea3 First commit to Fossee of testapp has the basic Pykata framework on django with some specific changes to Problems model and some views to suit an exam like system
amit@thunder
parents:
diff changeset
    37
  class Meta:
0b061d58aea3 First commit to Fossee of testapp has the basic Pykata framework on django with some specific changes to Problems model and some views to suit an exam like system
amit@thunder
parents:
diff changeset
    38
   model = models.Problem
0b061d58aea3 First commit to Fossee of testapp has the basic Pykata framework on django with some specific changes to Problems model and some views to suit an exam like system
amit@thunder
parents:
diff changeset
    39
   exclude = ('author', 'created', 'modified')
0b061d58aea3 First commit to Fossee of testapp has the basic Pykata framework on django with some specific changes to Problems model and some views to suit an exam like system
amit@thunder
parents:
diff changeset
    40
0b061d58aea3 First commit to Fossee of testapp has the basic Pykata framework on django with some specific changes to Problems model and some views to suit an exam like system
amit@thunder
parents:
diff changeset
    41
0b061d58aea3 First commit to Fossee of testapp has the basic Pykata framework on django with some specific changes to Problems model and some views to suit an exam like system
amit@thunder
parents:
diff changeset
    42
0b061d58aea3 First commit to Fossee of testapp has the basic Pykata framework on django with some specific changes to Problems model and some views to suit an exam like system
amit@thunder
parents:
diff changeset
    43
class Test_UserForm(RegistrationForm):
0b061d58aea3 First commit to Fossee of testapp has the basic Pykata framework on django with some specific changes to Problems model and some views to suit an exam like system
amit@thunder
parents:
diff changeset
    44
0b061d58aea3 First commit to Fossee of testapp has the basic Pykata framework on django with some specific changes to Problems model and some views to suit an exam like system
amit@thunder
parents:
diff changeset
    45
  fullname = forms.CharField(widget=forms.TextInput(attrs=attrs_dict))
0b061d58aea3 First commit to Fossee of testapp has the basic Pykata framework on django with some specific changes to Problems model and some views to suit an exam like system
amit@thunder
parents:
diff changeset
    46
  class Meta:
0b061d58aea3 First commit to Fossee of testapp has the basic Pykata framework on django with some specific changes to Problems model and some views to suit an exam like system
amit@thunder
parents:
diff changeset
    47
        exclude = ('special_user',)
0b061d58aea3 First commit to Fossee of testapp has the basic Pykata framework on django with some specific changes to Problems model and some views to suit an exam like system
amit@thunder
parents:
diff changeset
    48
0b061d58aea3 First commit to Fossee of testapp has the basic Pykata framework on django with some specific changes to Problems model and some views to suit an exam like system
amit@thunder
parents:
diff changeset
    49
0b061d58aea3 First commit to Fossee of testapp has the basic Pykata framework on django with some specific changes to Problems model and some views to suit an exam like system
amit@thunder
parents:
diff changeset
    50
  def save(self, profile_callback=None):
0b061d58aea3 First commit to Fossee of testapp has the basic Pykata framework on django with some specific changes to Problems model and some views to suit an exam like system
amit@thunder
parents:
diff changeset
    51
    new_user = RegistrationProfile.objects.create_inactive_user(username=self.cleaned_data['username'],
0b061d58aea3 First commit to Fossee of testapp has the basic Pykata framework on django with some specific changes to Problems model and some views to suit an exam like system
amit@thunder
parents:
diff changeset
    52
                                                                password=self.cleaned_data['password1'],
0b061d58aea3 First commit to Fossee of testapp has the basic Pykata framework on django with some specific changes to Problems model and some views to suit an exam like system
amit@thunder
parents:
diff changeset
    53
                                                                email=self.cleaned_data['email'])
0b061d58aea3 First commit to Fossee of testapp has the basic Pykata framework on django with some specific changes to Problems model and some views to suit an exam like system
amit@thunder
parents:
diff changeset
    54
    new_profile = Test_User(user=new_user, fullname=self.cleaned_data[fullname])
0b061d58aea3 First commit to Fossee of testapp has the basic Pykata framework on django with some specific changes to Problems model and some views to suit an exam like system
amit@thunder
parents:
diff changeset
    55
    new_profile.save()
0b061d58aea3 First commit to Fossee of testapp has the basic Pykata framework on django with some specific changes to Problems model and some views to suit an exam like system
amit@thunder
parents:
diff changeset
    56
    return new_user
0b061d58aea3 First commit to Fossee of testapp has the basic Pykata framework on django with some specific changes to Problems model and some views to suit an exam like system
amit@thunder
parents:
diff changeset
    57
0b061d58aea3 First commit to Fossee of testapp has the basic Pykata framework on django with some specific changes to Problems model and some views to suit an exam like system
amit@thunder
parents:
diff changeset
    58
0b061d58aea3 First commit to Fossee of testapp has the basic Pykata framework on django with some specific changes to Problems model and some views to suit an exam like system
amit@thunder
parents:
diff changeset
    59
0b061d58aea3 First commit to Fossee of testapp has the basic Pykata framework on django with some specific changes to Problems model and some views to suit an exam like system
amit@thunder
parents:
diff changeset
    60
class UploadForm(forms.Form):
0b061d58aea3 First commit to Fossee of testapp has the basic Pykata framework on django with some specific changes to Problems model and some views to suit an exam like system
amit@thunder
parents:
diff changeset
    61
  file = forms.FileField()
0b061d58aea3 First commit to Fossee of testapp has the basic Pykata framework on django with some specific changes to Problems model and some views to suit an exam like system
amit@thunder
parents:
diff changeset
    62
0b061d58aea3 First commit to Fossee of testapp has the basic Pykata framework on django with some specific changes to Problems model and some views to suit an exam like system
amit@thunder
parents:
diff changeset
    63
  class Meta:
0b061d58aea3 First commit to Fossee of testapp has the basic Pykata framework on django with some specific changes to Problems model and some views to suit an exam like system
amit@thunder
parents:
diff changeset
    64
    model = None