--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/testappproj/testapp/forms.py Mon May 17 22:33:59 2010 +0530
@@ -0,0 +1,64 @@
+from django import forms
+from registration.forms import RegistrationForm
+from django.utils.translation import ugettext_lazy as _
+from testapp.models import Test_User
+from registration.models import RegistrationProfile
+#from google.appengine.ext.db import djangoforms
+import models
+
+
+attrs_dict = { 'class': 'required' }
+
+PROBLEM_CHOICES=(
+ ('P', 'Plotting'),
+ ('S', 'Scripting'),
+)
+
+SESSION_CHOICES=(
+ ('A','DAY 1 SESSION 1'),
+ ('B','DAY 1 SESSION 2'),
+ ('C','DAY 1 SESSION 3'),
+ ('D','DAY 1 SESSION 4'),
+ ('E','DAY 2 SESSION 1'),
+ ('F','DAY 2 SESSION 2'),
+ ('G','DAY 2 SESSION 3'),
+ ('H','DAY 2 SESSION 4'),
+ )
+
+
+class ProblemForm(forms.Form):
+ Description = forms.CharField(widget=forms.Textarea(attrs={'rows': '10', 'cols': '80'}),required=True,help_text="To be used as the question")
+ Problem_type = forms.ChoiceField(choices=PROBLEM_CHOICES,required=True)
+ Solution = forms.CharField(widget=forms.Textarea(attrs={'rows': '10', 'cols': '80'}),help_text="comma seperated in case of multiple solutions")
+ Solution_Image = forms.ImageField(required=False)
+ Session = forms.ChoiceField(choices=SESSION_CHOICES, required=True)
+
+
+ class Meta:
+ model = models.Problem
+ exclude = ('author', 'created', 'modified')
+
+
+
+class Test_UserForm(RegistrationForm):
+
+ fullname = forms.CharField(widget=forms.TextInput(attrs=attrs_dict))
+ class Meta:
+ exclude = ('special_user',)
+
+
+ def save(self, profile_callback=None):
+ new_user = RegistrationProfile.objects.create_inactive_user(username=self.cleaned_data['username'],
+ password=self.cleaned_data['password1'],
+ email=self.cleaned_data['email'])
+ new_profile = Test_User(user=new_user, fullname=self.cleaned_data[fullname])
+ new_profile.save()
+ return new_user
+
+
+
+class UploadForm(forms.Form):
+ file = forms.FileField()
+
+ class Meta:
+ model = None