author | Lennard de Rijk <ljvderijk@gmail.com> |
Tue, 11 Aug 2009 10:22:01 -0700 | |
changeset 2754 | efbce6839e90 |
parent 2076 | 1cd180cc56c9 |
permissions | -rw-r--r-- |
460
3a508b1ebaac
Added a generic user page
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
1 |
#!/usr/bin/python2.5 |
3a508b1ebaac
Added a generic user page
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
2 |
# |
1308
35b75ffcbb37
Partially reverted "Update the copyright notice for 2009."
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1307
diff
changeset
|
3 |
# Copyright 2008 the Melange authors. |
460
3a508b1ebaac
Added a generic user page
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
4 |
# |
3a508b1ebaac
Added a generic user page
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
5 |
# Licensed under the Apache License, Version 2.0 (the "License"); |
3a508b1ebaac
Added a generic user page
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
6 |
# you may not use this file except in compliance with the License. |
3a508b1ebaac
Added a generic user page
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
7 |
# You may obtain a copy of the License at |
3a508b1ebaac
Added a generic user page
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
8 |
# |
3a508b1ebaac
Added a generic user page
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
9 |
# http://www.apache.org/licenses/LICENSE-2.0 |
3a508b1ebaac
Added a generic user page
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
10 |
# |
3a508b1ebaac
Added a generic user page
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
11 |
# Unless required by applicable law or agreed to in writing, software |
3a508b1ebaac
Added a generic user page
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
12 |
# distributed under the License is distributed on an "AS IS" BASIS, |
3a508b1ebaac
Added a generic user page
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
13 |
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
3a508b1ebaac
Added a generic user page
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
14 |
# See the License for the specific language governing permissions and |
3a508b1ebaac
Added a generic user page
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
15 |
# limitations under the License. |
3a508b1ebaac
Added a generic user page
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
16 |
|
590
37735d97b541
Created a seperate module for editSelf things
Sverre Rabbelier <srabbelier@gmail.com>
parents:
587
diff
changeset
|
17 |
"""Views for User profiles. |
460
3a508b1ebaac
Added a generic user page
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
18 |
""" |
3a508b1ebaac
Added a generic user page
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
19 |
|
3a508b1ebaac
Added a generic user page
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
20 |
__authors__ = [ |
3a508b1ebaac
Added a generic user page
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
21 |
'"Sverre Rabbelier" <sverre@rabbelier.nl>', |
1042
edd125206703
Renamed _getToSExampleText to getToSExampleText in soc/views/models/user.py.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1030
diff
changeset
|
22 |
'"Lennard de Rijk" <ljvderijk@gmail.com>', |
470
7ba510d3fad3
In soc.views.models.user module fix too long line. Delete unused email variable, add missing doc and rename self method and global variable to editSelf and edit_self so it's not confused with "self" used in classes and there is no outerscope variable name overwriting anymore.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
460
diff
changeset
|
23 |
'"Pawel Solyga" <pawel.solyga@gmail.com>', |
460
3a508b1ebaac
Added a generic user page
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
24 |
] |
3a508b1ebaac
Added a generic user page
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
25 |
|
499
d22e4fe8e64b
Fix missing dots in doc strings and some other doc string corrections.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
495
diff
changeset
|
26 |
|
460
3a508b1ebaac
Added a generic user page
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
27 |
from django import forms |
3a508b1ebaac
Added a generic user page
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
28 |
|
1014
508ad99368e2
soc/views/models/user.py now uses dynaform and appropriate cleaning methods.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
934
diff
changeset
|
29 |
from soc.logic import cleaning |
460
3a508b1ebaac
Added a generic user page
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
30 |
from soc.logic import dicts |
856
3d14b31e72e4
Set agrees_to_tos example text to link to site-wide ToS (or a warning message).
Todd Larsen <tlarsen@google.com>
parents:
813
diff
changeset
|
31 |
from soc.logic.models.site import logic as site_logic |
3d14b31e72e4
Set agrees_to_tos example text to link to site-wide ToS (or a warning message).
Todd Larsen <tlarsen@google.com>
parents:
813
diff
changeset
|
32 |
from soc.logic.models.user import logic as user_logic |
1014
508ad99368e2
soc/views/models/user.py now uses dynaform and appropriate cleaning methods.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
934
diff
changeset
|
33 |
from soc.views.helper import access |
1583 | 34 |
from soc.views.helper import decorators |
891
3d40190f35b6
Move getToSLink() to soc.views.helper.redirects.getToSRedirect().
Todd Larsen <tlarsen@google.com>
parents:
858
diff
changeset
|
35 |
from soc.views.helper import redirects |
1014
508ad99368e2
soc/views/models/user.py now uses dynaform and appropriate cleaning methods.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
934
diff
changeset
|
36 |
from soc.views.helper import widgets |
460
3a508b1ebaac
Added a generic user page
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
37 |
from soc.views.models import base |
3a508b1ebaac
Added a generic user page
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
38 |
|
549
00a9ce3dc082
Fix some broken help_text bubbles (they are truncated or not displayed if they
Todd Larsen <tlarsen@google.com>
parents:
547
diff
changeset
|
39 |
import soc.models.linkable |
460
3a508b1ebaac
Added a generic user page
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
40 |
import soc.logic.models.user |
3a508b1ebaac
Added a generic user page
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
41 |
import soc.views.helper |
3a508b1ebaac
Added a generic user page
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
42 |
|
3a508b1ebaac
Added a generic user page
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
43 |
|
3a508b1ebaac
Added a generic user page
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
44 |
class View(base.View): |
499
d22e4fe8e64b
Fix missing dots in doc strings and some other doc string corrections.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
495
diff
changeset
|
45 |
"""View methods for the User model. |
460
3a508b1ebaac
Added a generic user page
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
46 |
""" |
3a508b1ebaac
Added a generic user page
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
47 |
|
547
be0de865ffc9
Fixed former_accounts detection by supplying the missing error message.
Todd Larsen <tlarsen@google.com>
parents:
546
diff
changeset
|
48 |
|
656
a76f1b443ea4
Cleanups in the views module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
650
diff
changeset
|
49 |
def __init__(self, params=None): |
460
3a508b1ebaac
Added a generic user page
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
50 |
"""Defines the fields and methods required for the base View class |
3a508b1ebaac
Added a generic user page
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
51 |
to provide the user with list, public, create, edit and delete views. |
3a508b1ebaac
Added a generic user page
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
52 |
|
3a508b1ebaac
Added a generic user page
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
53 |
Params: |
656
a76f1b443ea4
Cleanups in the views module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
650
diff
changeset
|
54 |
params: a dict with params for this View |
460
3a508b1ebaac
Added a generic user page
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
55 |
""" |
3a508b1ebaac
Added a generic user page
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
56 |
|
1014
508ad99368e2
soc/views/models/user.py now uses dynaform and appropriate cleaning methods.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
934
diff
changeset
|
57 |
rights = access.Checker(params) |
508ad99368e2
soc/views/models/user.py now uses dynaform and appropriate cleaning methods.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
934
diff
changeset
|
58 |
rights['create'] = ['checkIsDeveloper'] |
508ad99368e2
soc/views/models/user.py now uses dynaform and appropriate cleaning methods.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
934
diff
changeset
|
59 |
rights['edit'] = ['checkIsDeveloper'] |
508ad99368e2
soc/views/models/user.py now uses dynaform and appropriate cleaning methods.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
934
diff
changeset
|
60 |
rights['delete'] = ['checkIsDeveloper'] |
1941
81fc81b62c5e
Explicitly added access check for public profile page view.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1856
diff
changeset
|
61 |
rights['show'] = ['allow'] |
1014
508ad99368e2
soc/views/models/user.py now uses dynaform and appropriate cleaning methods.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
934
diff
changeset
|
62 |
rights['list'] = ['checkIsDeveloper'] |
1856
44ccd96a5324
Added a list of developers to the User menu
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1796
diff
changeset
|
63 |
rights['list_developers'] = ['checkIsDeveloper'] |
1014
508ad99368e2
soc/views/models/user.py now uses dynaform and appropriate cleaning methods.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
934
diff
changeset
|
64 |
|
656
a76f1b443ea4
Cleanups in the views module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
650
diff
changeset
|
65 |
new_params = {} |
a76f1b443ea4
Cleanups in the views module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
650
diff
changeset
|
66 |
new_params['logic'] = soc.logic.models.user.logic |
1014
508ad99368e2
soc/views/models/user.py now uses dynaform and appropriate cleaning methods.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
934
diff
changeset
|
67 |
new_params['rights'] = rights |
508ad99368e2
soc/views/models/user.py now uses dynaform and appropriate cleaning methods.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
934
diff
changeset
|
68 |
|
656
a76f1b443ea4
Cleanups in the views module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
650
diff
changeset
|
69 |
new_params['name'] = "User" |
460
3a508b1ebaac
Added a generic user page
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
70 |
|
1014
508ad99368e2
soc/views/models/user.py now uses dynaform and appropriate cleaning methods.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
934
diff
changeset
|
71 |
new_params['edit_template'] = 'soc/user/edit.html' |
1480
d2d9087d712f
Make all default URLS customizable
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1430
diff
changeset
|
72 |
new_params['pickable'] = True |
1796
5cd78a7aacdd
Allow for query caching in pick
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1584
diff
changeset
|
73 |
new_params['cache_pick'] = True |
460
3a508b1ebaac
Added a generic user page
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
74 |
|
656
a76f1b443ea4
Cleanups in the views module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
650
diff
changeset
|
75 |
new_params['sidebar_heading'] = 'Users' |
542
7cc99461b64d
Remove redundant dicts for URL patterns and sidebar menu text, and use the
Todd Larsen <tlarsen@google.com>
parents:
531
diff
changeset
|
76 |
|
1076
063194eaf87b
Added agreed_to_tos_on field in user and role model.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1047
diff
changeset
|
77 |
new_params['extra_dynaexclude'] = ['former_accounts', 'agreed_to_tos', |
1157
76e2ed09661c
Added status property to the user model.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1079
diff
changeset
|
78 |
'agreed_to_tos_on', 'status'] |
1430
ff8cc6b15e6a
Rename dynafields to dynaproperties
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1343
diff
changeset
|
79 |
new_params['create_extra_dynaproperties'] = { |
1014
508ad99368e2
soc/views/models/user.py now uses dynaform and appropriate cleaning methods.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
934
diff
changeset
|
80 |
'clean_link_id': cleaning.clean_user_not_exist('link_id'), |
508ad99368e2
soc/views/models/user.py now uses dynaform and appropriate cleaning methods.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
934
diff
changeset
|
81 |
'clean_account': cleaning.clean_user_account_not_in_use('account')} |
508ad99368e2
soc/views/models/user.py now uses dynaform and appropriate cleaning methods.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
934
diff
changeset
|
82 |
|
1157
76e2ed09661c
Added status property to the user model.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1079
diff
changeset
|
83 |
# recreate the choices for the edit form |
76e2ed09661c
Added status property to the user model.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1079
diff
changeset
|
84 |
status_choices = [] |
76e2ed09661c
Added status property to the user model.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1079
diff
changeset
|
85 |
for choice in user_logic.getModel().status.choices: |
76e2ed09661c
Added status property to the user model.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1079
diff
changeset
|
86 |
status_choices.append((choice, choice)) |
76e2ed09661c
Added status property to the user model.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1079
diff
changeset
|
87 |
|
1430
ff8cc6b15e6a
Rename dynafields to dynaproperties
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1343
diff
changeset
|
88 |
new_params['edit_extra_dynaproperties'] = { |
1030
a0081c626acb
Style fixes in soc.views.models modules.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
1014
diff
changeset
|
89 |
'link_id': forms.CharField(widget=widgets.ReadOnlyInput(), |
1076
063194eaf87b
Added agreed_to_tos_on field in user and role model.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1047
diff
changeset
|
90 |
required=True), |
1079
be1aacb33b0f
Changed clean_link_id to be in a wrapper form as well.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1076
diff
changeset
|
91 |
'clean_link_id': cleaning.clean_link_id('link_id'), |
1172
6404a939412c
Style fixes in soc.views.models.user module.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
1159
diff
changeset
|
92 |
'agreed_to_tos_on': forms.DateTimeField( |
1159
3fefc88b0965
Fixes an error occurring when editing a User as Developer when the ToS have been signed.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1157
diff
changeset
|
93 |
widget=widgets.ReadOnlyInput(attrs={'disabled':'true'}), |
1076
063194eaf87b
Added agreed_to_tos_on field in user and role model.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1047
diff
changeset
|
94 |
required=False), |
1172
6404a939412c
Style fixes in soc.views.models.user module.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
1159
diff
changeset
|
95 |
'status': forms.ChoiceField(choices=status_choices), |
1014
508ad99368e2
soc/views/models/user.py now uses dynaform and appropriate cleaning methods.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
934
diff
changeset
|
96 |
'clean_account': cleaning.clean_user_account('account'), |
1030
a0081c626acb
Style fixes in soc.views.models modules.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
1014
diff
changeset
|
97 |
'clean': cleaning.validate_user_edit('link_id', 'account'), |
1014
508ad99368e2
soc/views/models/user.py now uses dynaform and appropriate cleaning methods.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
934
diff
changeset
|
98 |
} |
1076
063194eaf87b
Added agreed_to_tos_on field in user and role model.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1047
diff
changeset
|
99 |
|
1856
44ccd96a5324
Added a list of developers to the User menu
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1796
diff
changeset
|
100 |
patterns = [] |
44ccd96a5324
Added a list of developers to the User menu
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1796
diff
changeset
|
101 |
|
44ccd96a5324
Added a list of developers to the User menu
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1796
diff
changeset
|
102 |
patterns += [(r'^%(url_name)s/(?P<access_type>list_developers)$', |
44ccd96a5324
Added a list of developers to the User menu
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1796
diff
changeset
|
103 |
'soc.views.models.%(module_name)s.list_developers', |
44ccd96a5324
Added a list of developers to the User menu
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1796
diff
changeset
|
104 |
"List Developers")] |
44ccd96a5324
Added a list of developers to the User menu
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1796
diff
changeset
|
105 |
|
44ccd96a5324
Added a list of developers to the User menu
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1796
diff
changeset
|
106 |
new_params['extra_django_patterns'] = patterns |
44ccd96a5324
Added a list of developers to the User menu
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1796
diff
changeset
|
107 |
|
44ccd96a5324
Added a list of developers to the User menu
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1796
diff
changeset
|
108 |
new_params['sidebar_additional'] = [ |
44ccd96a5324
Added a list of developers to the User menu
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1796
diff
changeset
|
109 |
('/user/list_developers' % new_params, |
44ccd96a5324
Added a list of developers to the User menu
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1796
diff
changeset
|
110 |
'List Developers', 'list_developers'),] |
44ccd96a5324
Added a list of developers to the User menu
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1796
diff
changeset
|
111 |
|
656
a76f1b443ea4
Cleanups in the views module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
650
diff
changeset
|
112 |
params = dicts.merge(params, new_params) |
460
3a508b1ebaac
Added a generic user page
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
113 |
|
656
a76f1b443ea4
Cleanups in the views module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
650
diff
changeset
|
114 |
super(View, self).__init__(params=params) |
460
3a508b1ebaac
Added a generic user page
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
115 |
|
1856
44ccd96a5324
Added a list of developers to the User menu
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1796
diff
changeset
|
116 |
def listDevelopers(self, request, access_type, page_name=None, params=None): |
44ccd96a5324
Added a list of developers to the User menu
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1796
diff
changeset
|
117 |
"""See base.View.list. |
44ccd96a5324
Added a list of developers to the User menu
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1796
diff
changeset
|
118 |
""" |
44ccd96a5324
Added a list of developers to the User menu
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1796
diff
changeset
|
119 |
|
44ccd96a5324
Added a list of developers to the User menu
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1796
diff
changeset
|
120 |
filter = {'is_developer': True} |
44ccd96a5324
Added a list of developers to the User menu
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1796
diff
changeset
|
121 |
|
44ccd96a5324
Added a list of developers to the User menu
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1796
diff
changeset
|
122 |
return self.list(request, access_type, page_name=page_name, |
44ccd96a5324
Added a list of developers to the User menu
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1796
diff
changeset
|
123 |
params=params, filter=filter) |
543
280a1ac6bcc1
Merge soc/logic/out_of_band.py into soc/views/out_of_band.py. Merge
Todd Larsen <tlarsen@google.com>
parents:
542
diff
changeset
|
124 |
|
479
50bab5e71a66
Make sure the user edit form has the complete mail adress in the user account field when opened. Replace confusing id field in form with email field. Editing the email adress of an existing user will still result in an error but that should be fixed soon.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
473
diff
changeset
|
125 |
def _editGet(self, request, entity, form): |
50bab5e71a66
Make sure the user edit form has the complete mail adress in the user account field when opened. Replace confusing id field in form with email field. Editing the email adress of an existing user will still result in an error but that should be fixed soon.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
473
diff
changeset
|
126 |
"""See base.View._editGet(). |
50bab5e71a66
Make sure the user edit form has the complete mail adress in the user account field when opened. Replace confusing id field in form with email field. Editing the email adress of an existing user will still result in an error but that should be fixed soon.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
473
diff
changeset
|
127 |
""" |
662
0e89b027b140
Make use of the new generic key_name by lookup up scope_path
Sverre Rabbelier <srabbelier@gmail.com>
parents:
656
diff
changeset
|
128 |
|
479
50bab5e71a66
Make sure the user edit form has the complete mail adress in the user account field when opened. Replace confusing id field in form with email field. Editing the email adress of an existing user will still result in an error but that should be fixed soon.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
473
diff
changeset
|
129 |
# fill in the email field with the data from the entity |
1190
449b9d93d890
Probably fixed a bug on the live instance.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1172
diff
changeset
|
130 |
form.fields['account'].initial = entity.account.email |
1076
063194eaf87b
Added agreed_to_tos_on field in user and role model.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1047
diff
changeset
|
131 |
form.fields['agreed_to_tos_on'].initial = entity.agreed_to_tos_on |
063194eaf87b
Added agreed_to_tos_on field in user and role model.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1047
diff
changeset
|
132 |
form.fields['agreed_to_tos_on'].example_text = self._getToSExampleText() |
1157
76e2ed09661c
Added status property to the user model.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1079
diff
changeset
|
133 |
form.fields['status'].initial = entity.status |
460
3a508b1ebaac
Added a generic user page
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
134 |
|
662
0e89b027b140
Make use of the new generic key_name by lookup up scope_path
Sverre Rabbelier <srabbelier@gmail.com>
parents:
656
diff
changeset
|
135 |
super(View, self)._editGet(request, entity, form) |
0e89b027b140
Make use of the new generic key_name by lookup up scope_path
Sverre Rabbelier <srabbelier@gmail.com>
parents:
656
diff
changeset
|
136 |
|
1047
26fade94886b
Changed the Terms Of Service boolean so that it is None as long as the user owning the account has not Agreed to it.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1042
diff
changeset
|
137 |
|
1076
063194eaf87b
Added agreed_to_tos_on field in user and role model.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1047
diff
changeset
|
138 |
def _getToSExampleText(self): |
856
3d14b31e72e4
Set agrees_to_tos example text to link to site-wide ToS (or a warning message).
Todd Larsen <tlarsen@google.com>
parents:
813
diff
changeset
|
139 |
"""Returns example_text linking to site-wide ToS, or a warning message. |
3d14b31e72e4
Set agrees_to_tos example text to link to site-wide ToS (or a warning message).
Todd Larsen <tlarsen@google.com>
parents:
813
diff
changeset
|
140 |
""" |
891
3d40190f35b6
Move getToSLink() to soc.views.helper.redirects.getToSRedirect().
Todd Larsen <tlarsen@google.com>
parents:
858
diff
changeset
|
141 |
tos_link = redirects.getToSRedirect(site_logic.getSingleton()) |
856
3d14b31e72e4
Set agrees_to_tos example text to link to site-wide ToS (or a warning message).
Todd Larsen <tlarsen@google.com>
parents:
813
diff
changeset
|
142 |
|
3d14b31e72e4
Set agrees_to_tos example text to link to site-wide ToS (or a warning message).
Todd Larsen <tlarsen@google.com>
parents:
813
diff
changeset
|
143 |
if not tos_link: |
3d14b31e72e4
Set agrees_to_tos example text to link to site-wide ToS (or a warning message).
Todd Larsen <tlarsen@google.com>
parents:
813
diff
changeset
|
144 |
return ('<div class="notice"> <i>No site-wide</i> Terms of' |
3d14b31e72e4
Set agrees_to_tos example text to link to site-wide ToS (or a warning message).
Todd Larsen <tlarsen@google.com>
parents:
813
diff
changeset
|
145 |
' Service <i>are currently set!</i> </div>') |
3d14b31e72e4
Set agrees_to_tos example text to link to site-wide ToS (or a warning message).
Todd Larsen <tlarsen@google.com>
parents:
813
diff
changeset
|
146 |
|
3d14b31e72e4
Set agrees_to_tos example text to link to site-wide ToS (or a warning message).
Todd Larsen <tlarsen@google.com>
parents:
813
diff
changeset
|
147 |
return ('<i>current site-wide <b><a href=%s>Terms of Service</a></b></i>' |
3d14b31e72e4
Set agrees_to_tos example text to link to site-wide ToS (or a warning message).
Todd Larsen <tlarsen@google.com>
parents:
813
diff
changeset
|
148 |
% tos_link) |
3d14b31e72e4
Set agrees_to_tos example text to link to site-wide ToS (or a warning message).
Todd Larsen <tlarsen@google.com>
parents:
813
diff
changeset
|
149 |
|
3d14b31e72e4
Set agrees_to_tos example text to link to site-wide ToS (or a warning message).
Todd Larsen <tlarsen@google.com>
parents:
813
diff
changeset
|
150 |
|
460
3a508b1ebaac
Added a generic user page
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
151 |
view = View() |
3a508b1ebaac
Added a generic user page
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
152 |
|
1584
d8ba8c917f37
Make use of decorators.view for all views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1583
diff
changeset
|
153 |
admin = decorators.view(view.admin) |
d8ba8c917f37
Make use of decorators.view for all views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1583
diff
changeset
|
154 |
create = decorators.view(view.create) |
d8ba8c917f37
Make use of decorators.view for all views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1583
diff
changeset
|
155 |
delete = decorators.view(view.delete) |
d8ba8c917f37
Make use of decorators.view for all views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1583
diff
changeset
|
156 |
edit = decorators.view(view.edit) |
d8ba8c917f37
Make use of decorators.view for all views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1583
diff
changeset
|
157 |
list = decorators.view(view.list) |
1856
44ccd96a5324
Added a list of developers to the User menu
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1796
diff
changeset
|
158 |
list_developers = decorators.view(view.listDevelopers) |
1584
d8ba8c917f37
Make use of decorators.view for all views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1583
diff
changeset
|
159 |
public = decorators.view(view.public) |
d8ba8c917f37
Make use of decorators.view for all views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1583
diff
changeset
|
160 |
export = decorators.view(view.export) |
d8ba8c917f37
Make use of decorators.view for all views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1583
diff
changeset
|
161 |
pick = decorators.view(view.pick) |