2012-04-21 10:35:01 +00:00
|
|
|
import floppyforms as forms
|
2012-02-02 10:43:34 +00:00
|
|
|
from registration.forms import RegistrationForm
|
2012-04-21 10:35:01 +00:00
|
|
|
from models import *
|
2012-02-02 10:43:34 +00:00
|
|
|
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
|
2012-04-21 10:35:01 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#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')
|
|
|
|
|
|
|
|
|