6
|
1 |
#!/usr/bin/python2.5
|
|
2 |
|
|
3 |
from django import forms
|
16
|
4 |
from pytask.taskapp.models import GENDER_CHOICES, Profile
|
|
5 |
from django.forms import ModelForm
|
6
|
6 |
|
|
7 |
class RegistrationForm(forms.Form):
|
|
8 |
username = forms.CharField(max_length=30, required=True)
|
|
9 |
password = forms.CharField(max_length=60, required=True, widget=forms.PasswordInput)
|
|
10 |
repeat_password = forms.CharField(max_length=60, required=True, widget=forms.PasswordInput)
|
|
11 |
email = forms.EmailField(max_length=30, required=True)
|
|
12 |
gender = forms.ChoiceField(choices=GENDER_CHOICES, required = True)
|
|
13 |
dob = forms.DateField(required=True, help_text = "(YYYY-MM-DD)")
|
|
14 |
|
|
15 |
class LoginForm(forms.Form):
|
|
16 |
username = forms.CharField(max_length=30, required=True)
|
|
17 |
password = forms.CharField(max_length=60, required=True, widget=forms.PasswordInput)
|
16
|
18 |
|
|
19 |
class UserProfileForm(ModelForm):
|
|
20 |
class Meta:
|
|
21 |
model = Profile
|
|
22 |
exclude = ('user','rights')
|
|
23 |
def __init__(self, *args, **kwargs):
|
|
24 |
super(UserProfileForm, self).__init__(*args, **kwargs)
|
|
25 |
instance = getattr(self, 'instance', None)
|
|
26 |
if instance and instance.id:
|
|
27 |
self.fields['dob'].widget.attrs['readonly'] = True
|
|
28 |
self.fields['gender'].widget.attrs['readonly'] = True
|
|
29 |
self.fields['credits'].widget.attrs['readonly'] = True
|
|
30 |
self.fields['aboutme'].widget.attrs['readonly'] = True
|
|
31 |
self.fields['foss_comm'].widget.attrs['readonly'] = True
|
|
32 |
self.fields['phonenum'].widget.attrs['readonly'] = True
|
|
33 |
self.fields['homepage'].widget.attrs['readonly'] = True
|
|
34 |
self.fields['street'].widget.attrs['readonly'] = True
|
|
35 |
self.fields['city'].widget.attrs['readonly'] = True
|
|
36 |
self.fields['country'].widget.attrs['readonly'] = True
|
|
37 |
self.fields['nick'].widget.attrs['readonly'] = True
|
|
38 |
#fields = ['dob','gender','credits','aboutme','foss_comm','phonenum','homepage','street','city','country','nick']
|
|
39 |
|
|
40 |
class UserProfileEditForm(ModelForm):
|
|
41 |
class Meta:
|
|
42 |
model = Profile
|
|
43 |
exclude = ('user','rights','dob','credits')
|