testappproj/testapp/#forms.py#
author amit@thunder
Mon, 31 May 2010 19:18:57 +0530
changeset 2 654c583fd78e
parent 0 0b061d58aea3
permissions -rw-r--r--
Made some changes and templates

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'),
)



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()
  Session = forms.CharField(widget=forms.Textarea(attrs={'rows': '10', 'cols': '80'}), 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