|
1 from django import forms |
|
2 from registration.forms import RegistrationForm |
|
3 from django.utils.translation import ugettext_lazy as _ |
|
4 from testapp.models import Test_User |
|
5 from registration.models import RegistrationProfile |
|
6 #from google.appengine.ext.db import djangoforms |
|
7 import models |
|
8 |
|
9 |
|
10 attrs_dict = { 'class': 'required' } |
|
11 |
|
12 PROBLEM_CHOICES=( |
|
13 ('P', 'Plotting'), |
|
14 ('S', 'Scripting'), |
|
15 ) |
|
16 |
|
17 |
|
18 |
|
19 class ProblemForm(forms.Form): |
|
20 Description = forms.CharField(widget=forms.Textarea(attrs={'rows': '10', 'cols': '80'}),required=True,help_text="To be used as the question") |
|
21 Problem_type = forms.ChoiceField(choices=PROBLEM_CHOICES,required=True) |
|
22 Solution = forms.CharField(widget=forms.Textarea(attrs={'rows': '10', 'cols': '80'}),help_text="comma seperated in case of multiple solutions") |
|
23 Solution_Image = forms.ImageField() |
|
24 Session = forms.CharField(widget=forms.Textarea(attrs={'rows': '10', 'cols': '80'}), required=True) |
|
25 |
|
26 |
|
27 class Meta: |
|
28 model = models.Problem |
|
29 exclude = ('author', 'created', 'modified') |
|
30 |
|
31 |
|
32 |
|
33 class Test_UserForm(RegistrationForm): |
|
34 |
|
35 fullname = forms.CharField(widget=forms.TextInput(attrs=attrs_dict)) |
|
36 class Meta: |
|
37 exclude = ('special_user',) |
|
38 |
|
39 |
|
40 def save(self, profile_callback=None): |
|
41 new_user = RegistrationProfile.objects.create_inactive_user(username=self.cleaned_data['username'], |
|
42 password=self.cleaned_data['password1'], |
|
43 email=self.cleaned_data['email']) |
|
44 new_profile = Test_User(user=new_user, fullname=self.cleaned_data[fullname]) |
|
45 new_profile.save() |
|
46 return new_user |
|
47 |
|
48 |
|
49 |
|
50 class UploadForm(forms.Form): |
|
51 file = forms.FileField() |
|
52 |
|
53 class Meta: |
|
54 model = None |