diff options
author | anoop | 2010-02-04 23:12:07 +0530 |
---|---|---|
committer | anoop | 2010-02-04 23:12:07 +0530 |
commit | 00142ae87491e58a464e0d24232fee608293ea88 (patch) | |
tree | a4b9ef8a0d0d78a0628e1f7d5142a5ebc13f3b36 /taskapp/forms | |
parent | fcd65993031a3c9ac9b9d1d42f26fed3f21a3f70 (diff) | |
download | pytask-00142ae87491e58a464e0d24232fee608293ea88.tar.gz pytask-00142ae87491e58a464e0d24232fee608293ea88.tar.bz2 pytask-00142ae87491e58a464e0d24232fee608293ea88.zip |
added view profile and edit profile functionalities.
Diffstat (limited to 'taskapp/forms')
-rw-r--r-- | taskapp/forms/user.py | 29 |
1 files changed, 28 insertions, 1 deletions
diff --git a/taskapp/forms/user.py b/taskapp/forms/user.py index cca8173..b80ee81 100644 --- a/taskapp/forms/user.py +++ b/taskapp/forms/user.py @@ -1,7 +1,8 @@ #!/usr/bin/python2.5 from django import forms -from pytask.taskapp.models import GENDER_CHOICES +from pytask.taskapp.models import GENDER_CHOICES, Profile +from django.forms import ModelForm class RegistrationForm(forms.Form): username = forms.CharField(max_length=30, required=True) @@ -14,3 +15,29 @@ class RegistrationForm(forms.Form): class LoginForm(forms.Form): username = forms.CharField(max_length=30, required=True) password = forms.CharField(max_length=60, required=True, widget=forms.PasswordInput) + +class UserProfileForm(ModelForm): + class Meta: + model = Profile + exclude = ('user','rights') + def __init__(self, *args, **kwargs): + super(UserProfileForm, self).__init__(*args, **kwargs) + instance = getattr(self, 'instance', None) + if instance and instance.id: + self.fields['dob'].widget.attrs['readonly'] = True + self.fields['gender'].widget.attrs['readonly'] = True + self.fields['credits'].widget.attrs['readonly'] = True + self.fields['aboutme'].widget.attrs['readonly'] = True + self.fields['foss_comm'].widget.attrs['readonly'] = True + self.fields['phonenum'].widget.attrs['readonly'] = True + self.fields['homepage'].widget.attrs['readonly'] = True + self.fields['street'].widget.attrs['readonly'] = True + self.fields['city'].widget.attrs['readonly'] = True + self.fields['country'].widget.attrs['readonly'] = True + self.fields['nick'].widget.attrs['readonly'] = True + #fields = ['dob','gender','credits','aboutme','foss_comm','phonenum','homepage','street','city','country','nick'] + +class UserProfileEditForm(ModelForm): + class Meta: + model = Profile + exclude = ('user','rights','dob','credits') |