Mercurial > agora-palash
annotate apps/profile/forms.py @ 130:5ab229c9d348
Add back ability to edit account settings
* Account/profile editing is now done with a ModelForm, instead of processing
the data manually. Help text and verbose names have been moved to the
Profile model and to the UserForm (in the latter case, it's because we
can't edit the User model directly).
* The profile page now shows pygments style information and sections of the
profile that are not filled are now hidden.
* Some parts of apps/profiles/views.py have been rewritten (the getprofile()
method has been removed, as it's no longer necessary, and the editprofile()
view was rewritten in accordance with the switch to using ModelForms).
* The styling for forms has been modified slightly.
author | dellsystem <ilostwaldo@gmail.com> |
---|---|
date | Sat, 22 Sep 2012 11:18:23 -0400 |
parents | |
children | c7be7def8b57 |
rev | line source |
---|---|
130
5ab229c9d348
Add back ability to edit account settings
dellsystem <ilostwaldo@gmail.com>
parents:
diff
changeset
|
1 from django.forms import ModelForm |
5ab229c9d348
Add back ability to edit account settings
dellsystem <ilostwaldo@gmail.com>
parents:
diff
changeset
|
2 from django.contrib.auth.models import User |
5ab229c9d348
Add back ability to edit account settings
dellsystem <ilostwaldo@gmail.com>
parents:
diff
changeset
|
3 from django.utils.translation import ugettext as _ |
5ab229c9d348
Add back ability to edit account settings
dellsystem <ilostwaldo@gmail.com>
parents:
diff
changeset
|
4 |
5ab229c9d348
Add back ability to edit account settings
dellsystem <ilostwaldo@gmail.com>
parents:
diff
changeset
|
5 from agora.apps.profile.models import Profile |
5ab229c9d348
Add back ability to edit account settings
dellsystem <ilostwaldo@gmail.com>
parents:
diff
changeset
|
6 |
5ab229c9d348
Add back ability to edit account settings
dellsystem <ilostwaldo@gmail.com>
parents:
diff
changeset
|
7 |
5ab229c9d348
Add back ability to edit account settings
dellsystem <ilostwaldo@gmail.com>
parents:
diff
changeset
|
8 class ProfileForm(ModelForm): |
5ab229c9d348
Add back ability to edit account settings
dellsystem <ilostwaldo@gmail.com>
parents:
diff
changeset
|
9 class Meta: |
5ab229c9d348
Add back ability to edit account settings
dellsystem <ilostwaldo@gmail.com>
parents:
diff
changeset
|
10 model = Profile |
5ab229c9d348
Add back ability to edit account settings
dellsystem <ilostwaldo@gmail.com>
parents:
diff
changeset
|
11 exclude = ('user',) |
5ab229c9d348
Add back ability to edit account settings
dellsystem <ilostwaldo@gmail.com>
parents:
diff
changeset
|
12 |
5ab229c9d348
Add back ability to edit account settings
dellsystem <ilostwaldo@gmail.com>
parents:
diff
changeset
|
13 |
5ab229c9d348
Add back ability to edit account settings
dellsystem <ilostwaldo@gmail.com>
parents:
diff
changeset
|
14 class UserForm(ModelForm): |
5ab229c9d348
Add back ability to edit account settings
dellsystem <ilostwaldo@gmail.com>
parents:
diff
changeset
|
15 class Meta: |
5ab229c9d348
Add back ability to edit account settings
dellsystem <ilostwaldo@gmail.com>
parents:
diff
changeset
|
16 model = User |
5ab229c9d348
Add back ability to edit account settings
dellsystem <ilostwaldo@gmail.com>
parents:
diff
changeset
|
17 fields = ('first_name', 'last_name') |
5ab229c9d348
Add back ability to edit account settings
dellsystem <ilostwaldo@gmail.com>
parents:
diff
changeset
|
18 |
5ab229c9d348
Add back ability to edit account settings
dellsystem <ilostwaldo@gmail.com>
parents:
diff
changeset
|
19 def __init__(self, *args, **kwargs): |
5ab229c9d348
Add back ability to edit account settings
dellsystem <ilostwaldo@gmail.com>
parents:
diff
changeset
|
20 super(UserForm, self).__init__(*args, **kwargs) |
5ab229c9d348
Add back ability to edit account settings
dellsystem <ilostwaldo@gmail.com>
parents:
diff
changeset
|
21 |
5ab229c9d348
Add back ability to edit account settings
dellsystem <ilostwaldo@gmail.com>
parents:
diff
changeset
|
22 # Change the help text for names |
5ab229c9d348
Add back ability to edit account settings
dellsystem <ilostwaldo@gmail.com>
parents:
diff
changeset
|
23 name_text = _("We will display your name according to most Western \ |
5ab229c9d348
Add back ability to edit account settings
dellsystem <ilostwaldo@gmail.com>
parents:
diff
changeset
|
24 European conventions, your given name(s) followed by your surname(s).") |
5ab229c9d348
Add back ability to edit account settings
dellsystem <ilostwaldo@gmail.com>
parents:
diff
changeset
|
25 self.fields['first_name'].help_text = name_text |