it/itf/itfprofiles/forms.py
2012-04-21 16:05:01 +05:30

33 lines
1.2 KiB
Python

import floppyforms as forms
from registration.forms import RegistrationForm
from models import *
from registration.models import RegistrationProfile
class ItfRegistrationForm(RegistrationForm):
subscribe = forms.BooleanField(help_text='Subscribe to newsletter?')
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 = ItfProfile(user=new_user, subscribed=self.cleaned_data['subscribe'])
new_profile.save()
return new_user
#Actual person form definition
class PersonForm(forms.ModelForm):
# occupations = forms.ModelMultipleChoiceField(Occupation.objects.all(), widget=forms.CheckboxSelectMultiple())
email = forms.EmailField(widget=forms.EmailInput(attrs={'placeholder': 'john@example.com'}))
# inlines = [ConnectionFormset, ProductionFormset]
class Meta:
model = Person
widgets = {
'first_name': forms.TextInput,
'last_name': forms.TextInput,
'occupations': forms.CheckboxSelectMultiple
}
# exclude = ('connections', 'productions')