author | Lennard de Rijk <ljvderijk@gmail.com> |
Wed, 28 Jan 2009 15:43:30 +0000 | |
changeset 1043 | 5e15994b2033 |
parent 1017 | 6ad4fdb48840 |
child 1047 | 26fade94886b |
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 |
# |
3a508b1ebaac
Added a generic user page
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
3 |
# Copyright 2008 the Melange authors. |
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 the User's own 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>', |
1043
5e15994b2033
Redone the user's profile page.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1017
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 google.appengine.api import users |
3a508b1ebaac
Added a generic user page
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
28 |
|
630
0ac985fd8efa
Add missing import, remove unused import and add missing parameters to methods in soc.views.models.user_self module.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
612
diff
changeset
|
29 |
from django import http |
826
c8dbcfd38c03
Add an unread count indication next to the notification link
Sverre Rabbelier <srabbelier@gmail.com>
parents:
825
diff
changeset
|
30 |
from django.utils.encoding import force_unicode |
c8dbcfd38c03
Add an unread count indication next to the notification link
Sverre Rabbelier <srabbelier@gmail.com>
parents:
825
diff
changeset
|
31 |
from django.utils.safestring import mark_safe |
970
8b5611d5b053
Use ugettext instead of ugettext_lazy
Sverre Rabbelier <srabbelier@gmail.com>
parents:
890
diff
changeset
|
32 |
from django.utils.translation import ugettext |
460
3a508b1ebaac
Added a generic user page
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
33 |
|
1043
5e15994b2033
Redone the user's profile page.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1017
diff
changeset
|
34 |
from soc.logic import cleaning |
460
3a508b1ebaac
Added a generic user page
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
35 |
from soc.logic import dicts |
826
c8dbcfd38c03
Add an unread count indication next to the notification link
Sverre Rabbelier <srabbelier@gmail.com>
parents:
825
diff
changeset
|
36 |
from soc.logic import models as model_logic |
860
cfb57fe35d3c
Add a clean_agrees_to_tos() validator that requires "Yes" if ToS exists.
Todd Larsen <tlarsen@google.com>
parents:
858
diff
changeset
|
37 |
from soc.logic.models.user import logic as user_logic |
460
3a508b1ebaac
Added a generic user page
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
38 |
from soc.views import helper |
515
fa235f6759f3
Moved the last remnant of soc.views.user.profile to soc.views.models
Sverre Rabbelier <srabbelier@gmail.com>
parents:
514
diff
changeset
|
39 |
from soc.views.helper import access |
876
0c1329d4b514
Make use of the new decorators in all applicable views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
860
diff
changeset
|
40 |
from soc.views.helper import decorators |
1043
5e15994b2033
Redone the user's profile page.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1017
diff
changeset
|
41 |
from soc.views.helper import widgets |
460
3a508b1ebaac
Added a generic user page
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
42 |
from soc.views.models import base |
1043
5e15994b2033
Redone the user's profile page.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1017
diff
changeset
|
43 |
from soc.views.models import user as user_view |
515
fa235f6759f3
Moved the last remnant of soc.views.user.profile to soc.views.models
Sverre Rabbelier <srabbelier@gmail.com>
parents:
514
diff
changeset
|
44 |
|
1043
5e15994b2033
Redone the user's profile page.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1017
diff
changeset
|
45 |
import soc.models.user |
860
cfb57fe35d3c
Add a clean_agrees_to_tos() validator that requires "Yes" if ToS exists.
Todd Larsen <tlarsen@google.com>
parents:
858
diff
changeset
|
46 |
|
515
fa235f6759f3
Moved the last remnant of soc.views.user.profile to soc.views.models
Sverre Rabbelier <srabbelier@gmail.com>
parents:
514
diff
changeset
|
47 |
|
460
3a508b1ebaac
Added a generic user page
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
48 |
class View(base.View): |
1043
5e15994b2033
Redone the user's profile page.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1017
diff
changeset
|
49 |
"""Views for User own profiles. |
460
3a508b1ebaac
Added a generic user page
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
50 |
""" |
3a508b1ebaac
Added a generic user page
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
51 |
|
656
a76f1b443ea4
Cleanups in the views module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
650
diff
changeset
|
52 |
def __init__(self, params=None): |
460
3a508b1ebaac
Added a generic user page
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
53 |
"""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
|
54 |
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
|
55 |
|
3a508b1ebaac
Added a generic user page
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
56 |
Params: |
656
a76f1b443ea4
Cleanups in the views module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
650
diff
changeset
|
57 |
params: a dict with params for this View |
460
3a508b1ebaac
Added a generic user page
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
58 |
""" |
3a508b1ebaac
Added a generic user page
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
59 |
|
1007
3b66772d21a5
Major refactor of the access module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
973
diff
changeset
|
60 |
rights = access.Checker(params) |
3b66772d21a5
Major refactor of the access module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
973
diff
changeset
|
61 |
rights['unspecified'] = ['deny'] |
3b66772d21a5
Major refactor of the access module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
973
diff
changeset
|
62 |
rights['any_access'] = ['allow'] |
1043
5e15994b2033
Redone the user's profile page.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1017
diff
changeset
|
63 |
rights['create_profile'] = ['checkIsUnusedAccount'] |
5e15994b2033
Redone the user's profile page.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1017
diff
changeset
|
64 |
rights['edit_profile'] = ['checkHasUserEntity'] |
1012
73f0b61f2d9d
Fold checkAgreesToSiteToS into checkIsUser
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1007
diff
changeset
|
65 |
rights['roles'] = ['checkIsUser'] |
1007
3b66772d21a5
Major refactor of the access module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
973
diff
changeset
|
66 |
rights['signIn'] = ['checkNotLoggedIn'] |
1012
73f0b61f2d9d
Fold checkAgreesToSiteToS into checkIsUser
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1007
diff
changeset
|
67 |
rights['notification'] = ['checkIsUser'] |
587
7504504209a3
Fixed some access related bugs
Sverre Rabbelier <srabbelier@gmail.com>
parents:
586
diff
changeset
|
68 |
|
656
a76f1b443ea4
Cleanups in the views module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
650
diff
changeset
|
69 |
new_params = {} |
a76f1b443ea4
Cleanups in the views module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
650
diff
changeset
|
70 |
new_params['rights'] = rights |
860
cfb57fe35d3c
Add a clean_agrees_to_tos() validator that requires "Yes" if ToS exists.
Todd Larsen <tlarsen@google.com>
parents:
858
diff
changeset
|
71 |
new_params['logic'] = user_logic |
460
3a508b1ebaac
Added a generic user page
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
72 |
|
656
a76f1b443ea4
Cleanups in the views module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
650
diff
changeset
|
73 |
new_params['name'] = "User" |
799
30a912906a57
Construct names automatically from base name.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
787
diff
changeset
|
74 |
new_params['module_name'] = "user_self" |
656
a76f1b443ea4
Cleanups in the views module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
650
diff
changeset
|
75 |
new_params['url_name'] = "user" |
799
30a912906a57
Construct names automatically from base name.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
787
diff
changeset
|
76 |
|
1043
5e15994b2033
Redone the user's profile page.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1017
diff
changeset
|
77 |
new_params['create_template'] = 'soc/user/edit_profile.html' |
5e15994b2033
Redone the user's profile page.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1017
diff
changeset
|
78 |
new_params['edit_template'] = 'soc/user/edit_profile.html' |
5e15994b2033
Redone the user's profile page.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1017
diff
changeset
|
79 |
new_params['save_message'] = [ugettext('Profile saved.')] |
5e15994b2033
Redone the user's profile page.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1017
diff
changeset
|
80 |
new_params['edit_redirect'] = '/%(url_name)s/edit_profile' |
5e15994b2033
Redone the user's profile page.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1017
diff
changeset
|
81 |
|
5e15994b2033
Redone the user's profile page.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1017
diff
changeset
|
82 |
# set the specific fields for the users profile page |
5e15994b2033
Redone the user's profile page.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1017
diff
changeset
|
83 |
new_params['extra_dynaexclude'] = ['former_accounts', |
5e15994b2033
Redone the user's profile page.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1017
diff
changeset
|
84 |
'account', 'is_developer'] |
5e15994b2033
Redone the user's profile page.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1017
diff
changeset
|
85 |
new_params['create_extra_dynafields'] = { |
5e15994b2033
Redone the user's profile page.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1017
diff
changeset
|
86 |
'clean_agrees_to_tos' : cleaning.clean_agrees_to_tos('agrees_to_tos'), |
5e15994b2033
Redone the user's profile page.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1017
diff
changeset
|
87 |
'clean_link_id': cleaning.clean_user_not_exist('link_id'),} |
5e15994b2033
Redone the user's profile page.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1017
diff
changeset
|
88 |
|
5e15994b2033
Redone the user's profile page.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1017
diff
changeset
|
89 |
new_params['edit_extra_dynafields'] = { |
5e15994b2033
Redone the user's profile page.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1017
diff
changeset
|
90 |
'clean_link_id': cleaning.clean_link_id |
5e15994b2033
Redone the user's profile page.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1017
diff
changeset
|
91 |
} |
876
0c1329d4b514
Make use of the new decorators in all applicable views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
860
diff
changeset
|
92 |
|
696
0d8515fb5314
Make use of the 'sidebar' param for user_self
Sverre Rabbelier <srabbelier@gmail.com>
parents:
662
diff
changeset
|
93 |
new_params['sidebar_heading'] = 'User (self)' |
0d8515fb5314
Make use of the 'sidebar' param for user_self
Sverre Rabbelier <srabbelier@gmail.com>
parents:
662
diff
changeset
|
94 |
new_params['sidebar'] = [ |
1043
5e15994b2033
Redone the user's profile page.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1017
diff
changeset
|
95 |
(users.create_login_url("/"), 'Sign In', 'signIn'), |
5e15994b2033
Redone the user's profile page.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1017
diff
changeset
|
96 |
('/' + new_params['url_name'] + '/create_profile', 'Create Profile', 'create_profile'), |
5e15994b2033
Redone the user's profile page.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1017
diff
changeset
|
97 |
('/' + new_params['url_name'] + '/edit_profile', 'Edit Profile', 'edit_profile'), |
696
0d8515fb5314
Make use of the 'sidebar' param for user_self
Sverre Rabbelier <srabbelier@gmail.com>
parents:
662
diff
changeset
|
98 |
('/' + new_params['url_name'] + '/roles', 'Roles', 'roles'), |
0d8515fb5314
Make use of the 'sidebar' param for user_self
Sverre Rabbelier <srabbelier@gmail.com>
parents:
662
diff
changeset
|
99 |
] |
542
7cc99461b64d
Remove redundant dicts for URL patterns and sidebar menu text, and use the
Todd Larsen <tlarsen@google.com>
parents:
531
diff
changeset
|
100 |
|
660
5a381b290691
Introduced django_extra_patterns
Sverre Rabbelier <srabbelier@gmail.com>
parents:
656
diff
changeset
|
101 |
patterns = [] |
5a381b290691
Introduced django_extra_patterns
Sverre Rabbelier <srabbelier@gmail.com>
parents:
656
diff
changeset
|
102 |
|
1043
5e15994b2033
Redone the user's profile page.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1017
diff
changeset
|
103 |
page_name = ugettext("Create your profile") |
5e15994b2033
Redone the user's profile page.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1017
diff
changeset
|
104 |
patterns += [(r'^%(url_name)s/(?P<access_type>create_profile)$', |
5e15994b2033
Redone the user's profile page.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1017
diff
changeset
|
105 |
'soc.views.models.%(module_name)s.create', page_name)] |
5e15994b2033
Redone the user's profile page.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1017
diff
changeset
|
106 |
|
5e15994b2033
Redone the user's profile page.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1017
diff
changeset
|
107 |
page_name = ugettext("Edit your profile") |
5e15994b2033
Redone the user's profile page.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1017
diff
changeset
|
108 |
patterns += [(r'^%(url_name)s/(?P<access_type>edit_profile)$', |
660
5a381b290691
Introduced django_extra_patterns
Sverre Rabbelier <srabbelier@gmail.com>
parents:
656
diff
changeset
|
109 |
'soc.views.models.%(module_name)s.edit', page_name)] |
5a381b290691
Introduced django_extra_patterns
Sverre Rabbelier <srabbelier@gmail.com>
parents:
656
diff
changeset
|
110 |
|
1043
5e15994b2033
Redone the user's profile page.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1017
diff
changeset
|
111 |
page_name = ugettext("List of your roles") |
710
edb5dbb1dea7
Add explicit access_types from the url
Sverre Rabbelier <srabbelier@gmail.com>
parents:
696
diff
changeset
|
112 |
patterns += [(r'^%(url_name)s/(?P<access_type>roles)$', |
660
5a381b290691
Introduced django_extra_patterns
Sverre Rabbelier <srabbelier@gmail.com>
parents:
656
diff
changeset
|
113 |
'soc.views.models.request.list_self', page_name)] |
726 | 114 |
|
660
5a381b290691
Introduced django_extra_patterns
Sverre Rabbelier <srabbelier@gmail.com>
parents:
656
diff
changeset
|
115 |
new_params['django_patterns_defaults'] = patterns |
726 | 116 |
|
656
a76f1b443ea4
Cleanups in the views module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
650
diff
changeset
|
117 |
params = dicts.merge(params, new_params) |
460
3a508b1ebaac
Added a generic user page
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
118 |
|
656
a76f1b443ea4
Cleanups in the views module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
650
diff
changeset
|
119 |
super(View, self).__init__(params=params) |
460
3a508b1ebaac
Added a generic user page
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
120 |
|
1043
5e15994b2033
Redone the user's profile page.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1017
diff
changeset
|
121 |
|
876
0c1329d4b514
Make use of the new decorators in all applicable views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
860
diff
changeset
|
122 |
@decorators.merge_params |
0c1329d4b514
Make use of the new decorators in all applicable views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
860
diff
changeset
|
123 |
@decorators.check_access |
1043
5e15994b2033
Redone the user's profile page.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1017
diff
changeset
|
124 |
def editProfile(self, request, access_type, |
710
edb5dbb1dea7
Add explicit access_types from the url
Sverre Rabbelier <srabbelier@gmail.com>
parents:
696
diff
changeset
|
125 |
page_name=None, params=None, seed=None, **kwargs): |
1043
5e15994b2033
Redone the user's profile page.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1017
diff
changeset
|
126 |
"""Displays User profile edit page for the current user. |
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
|
127 |
|
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
|
128 |
Args: |
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
|
129 |
request: the standard Django HTTP request object |
500
44ea4620c5c0
Replace old page parameter doc string description with new one for page_name.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
499
diff
changeset
|
130 |
page_name: the page name displayed in templates as page and header title |
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
|
131 |
params: a dict with params for this View |
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
|
132 |
kwargs: The Key Fields for the specified entity |
460
3a508b1ebaac
Added a generic user page
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
133 |
""" |
3a508b1ebaac
Added a generic user page
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
134 |
|
1043
5e15994b2033
Redone the user's profile page.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1017
diff
changeset
|
135 |
# set the link_id to the current user's link_id |
5e15994b2033
Redone the user's profile page.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1017
diff
changeset
|
136 |
user_entity = user_logic.getForCurrentAccount() |
5e15994b2033
Redone the user's profile page.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1017
diff
changeset
|
137 |
link_id = user_entity.link_id |
515
fa235f6759f3
Moved the last remnant of soc.views.user.profile to soc.views.models
Sverre Rabbelier <srabbelier@gmail.com>
parents:
514
diff
changeset
|
138 |
|
1043
5e15994b2033
Redone the user's profile page.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1017
diff
changeset
|
139 |
return self.edit(request, access_type, |
5e15994b2033
Redone the user's profile page.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1017
diff
changeset
|
140 |
page_name=page_name, params=params, seed=seed, link_id=link_id, **kwargs) |
460
3a508b1ebaac
Added a generic user page
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
141 |
|
515
fa235f6759f3
Moved the last remnant of soc.views.user.profile to soc.views.models
Sverre Rabbelier <srabbelier@gmail.com>
parents:
514
diff
changeset
|
142 |
|
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
|
143 |
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
|
144 |
"""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
|
145 |
""" |
662
0e89b027b140
Make use of the new generic key_name by lookup up scope_path
Sverre Rabbelier <srabbelier@gmail.com>
parents:
660
diff
changeset
|
146 |
|
1043
5e15994b2033
Redone the user's profile page.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1017
diff
changeset
|
147 |
# set the ToS example text |
5e15994b2033
Redone the user's profile page.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1017
diff
changeset
|
148 |
form.fields['agrees_to_tos'].example_text = user_view.view.getToSExampleText() |
5e15994b2033
Redone the user's profile page.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1017
diff
changeset
|
149 |
form.fields['link_id'].initial = entity.link_id |
460
3a508b1ebaac
Added a generic user page
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
150 |
|
755
1ed041c0cdc6
Remove unused imports and variables in different soc.views.models modules.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
726
diff
changeset
|
151 |
super(View, self)._editGet(request, entity, form) |
662
0e89b027b140
Make use of the new generic key_name by lookup up scope_path
Sverre Rabbelier <srabbelier@gmail.com>
parents:
660
diff
changeset
|
152 |
|
460
3a508b1ebaac
Added a generic user page
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
153 |
def _editPost(self, request, entity, fields): |
3a508b1ebaac
Added a generic user page
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
154 |
"""See base.View._editPost(). |
3a508b1ebaac
Added a generic user page
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
155 |
""" |
662
0e89b027b140
Make use of the new generic key_name by lookup up scope_path
Sverre Rabbelier <srabbelier@gmail.com>
parents:
660
diff
changeset
|
156 |
|
1043
5e15994b2033
Redone the user's profile page.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1017
diff
changeset
|
157 |
# fill in the account field with the current User |
5e15994b2033
Redone the user's profile page.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1017
diff
changeset
|
158 |
fields['account'] = users.User() |
460
3a508b1ebaac
Added a generic user page
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
159 |
|
662
0e89b027b140
Make use of the new generic key_name by lookup up scope_path
Sverre Rabbelier <srabbelier@gmail.com>
parents:
660
diff
changeset
|
160 |
super(View, self)._editPost(request, entity, fields) |
0e89b027b140
Make use of the new generic key_name by lookup up scope_path
Sverre Rabbelier <srabbelier@gmail.com>
parents:
660
diff
changeset
|
161 |
|
1043
5e15994b2033
Redone the user's profile page.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1017
diff
changeset
|
162 |
|
1017
6ad4fdb48840
Cache access checks and disable sidebar caching
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1012
diff
changeset
|
163 |
def getSidebarMenus(self, id, user, params=None): |
837
bc1c951bf3a0
Add missing blank line in soc.views.helper.params module. Fix docstring typo in soc.views.models.role module. Add missing dots at the end of sentences in soc.logic.cleaning and soc.view.models.user_self modules.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
826
diff
changeset
|
164 |
"""See base.View.getSidebarMenus(). |
826
c8dbcfd38c03
Add an unread count indication next to the notification link
Sverre Rabbelier <srabbelier@gmail.com>
parents:
825
diff
changeset
|
165 |
""" |
c8dbcfd38c03
Add an unread count indication next to the notification link
Sverre Rabbelier <srabbelier@gmail.com>
parents:
825
diff
changeset
|
166 |
|
970
8b5611d5b053
Use ugettext instead of ugettext_lazy
Sverre Rabbelier <srabbelier@gmail.com>
parents:
890
diff
changeset
|
167 |
link_title = ugettext('Notifications') |
826
c8dbcfd38c03
Add an unread count indication next to the notification link
Sverre Rabbelier <srabbelier@gmail.com>
parents:
825
diff
changeset
|
168 |
|
c8dbcfd38c03
Add an unread count indication next to the notification link
Sverre Rabbelier <srabbelier@gmail.com>
parents:
825
diff
changeset
|
169 |
filter = { |
c8dbcfd38c03
Add an unread count indication next to the notification link
Sverre Rabbelier <srabbelier@gmail.com>
parents:
825
diff
changeset
|
170 |
'scope': user, |
c8dbcfd38c03
Add an unread count indication next to the notification link
Sverre Rabbelier <srabbelier@gmail.com>
parents:
825
diff
changeset
|
171 |
'unread': True, |
c8dbcfd38c03
Add an unread count indication next to the notification link
Sverre Rabbelier <srabbelier@gmail.com>
parents:
825
diff
changeset
|
172 |
} |
c8dbcfd38c03
Add an unread count indication next to the notification link
Sverre Rabbelier <srabbelier@gmail.com>
parents:
825
diff
changeset
|
173 |
|
c8dbcfd38c03
Add an unread count indication next to the notification link
Sverre Rabbelier <srabbelier@gmail.com>
parents:
825
diff
changeset
|
174 |
notifications = model_logic.notification.logic.getForFields(filter) |
c8dbcfd38c03
Add an unread count indication next to the notification link
Sverre Rabbelier <srabbelier@gmail.com>
parents:
825
diff
changeset
|
175 |
count = len(list(notifications)) |
c8dbcfd38c03
Add an unread count indication next to the notification link
Sverre Rabbelier <srabbelier@gmail.com>
parents:
825
diff
changeset
|
176 |
|
c8dbcfd38c03
Add an unread count indication next to the notification link
Sverre Rabbelier <srabbelier@gmail.com>
parents:
825
diff
changeset
|
177 |
if count > 0: |
c8dbcfd38c03
Add an unread count indication next to the notification link
Sverre Rabbelier <srabbelier@gmail.com>
parents:
825
diff
changeset
|
178 |
link_title = '<b>%s (%d)</b>' % (force_unicode(link_title), count) |
c8dbcfd38c03
Add an unread count indication next to the notification link
Sverre Rabbelier <srabbelier@gmail.com>
parents:
825
diff
changeset
|
179 |
link_title = mark_safe(link_title) |
c8dbcfd38c03
Add an unread count indication next to the notification link
Sverre Rabbelier <srabbelier@gmail.com>
parents:
825
diff
changeset
|
180 |
|
c8dbcfd38c03
Add an unread count indication next to the notification link
Sverre Rabbelier <srabbelier@gmail.com>
parents:
825
diff
changeset
|
181 |
items = [('/' + 'notification/list', link_title, 'notification')] |
c8dbcfd38c03
Add an unread count indication next to the notification link
Sverre Rabbelier <srabbelier@gmail.com>
parents:
825
diff
changeset
|
182 |
|
c8dbcfd38c03
Add an unread count indication next to the notification link
Sverre Rabbelier <srabbelier@gmail.com>
parents:
825
diff
changeset
|
183 |
new_params = {} |
840
d3f9fff0860b
When constructing the sidebar don't overide 'sidebar'
Sverre Rabbelier <srabbelier@gmail.com>
parents:
837
diff
changeset
|
184 |
new_params['sidebar_additional'] = items |
826
c8dbcfd38c03
Add an unread count indication next to the notification link
Sverre Rabbelier <srabbelier@gmail.com>
parents:
825
diff
changeset
|
185 |
|
c8dbcfd38c03
Add an unread count indication next to the notification link
Sverre Rabbelier <srabbelier@gmail.com>
parents:
825
diff
changeset
|
186 |
params = dicts.merge(params, new_params) |
c8dbcfd38c03
Add an unread count indication next to the notification link
Sverre Rabbelier <srabbelier@gmail.com>
parents:
825
diff
changeset
|
187 |
|
1017
6ad4fdb48840
Cache access checks and disable sidebar caching
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1012
diff
changeset
|
188 |
return super(View, self).getSidebarMenus(id, user, params=params) |
826
c8dbcfd38c03
Add an unread count indication next to the notification link
Sverre Rabbelier <srabbelier@gmail.com>
parents:
825
diff
changeset
|
189 |
|
460
3a508b1ebaac
Added a generic user page
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
190 |
|
3a508b1ebaac
Added a generic user page
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
191 |
view = View() |
3a508b1ebaac
Added a generic user page
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
192 |
|
1043
5e15994b2033
Redone the user's profile page.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1017
diff
changeset
|
193 |
create = view.create |
5e15994b2033
Redone the user's profile page.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1017
diff
changeset
|
194 |
edit = view.editProfile |
858
e79e7a22326f
Add an export() view, and implement it as text/text for Document.
Todd Larsen <tlarsen@google.com>
parents:
857
diff
changeset
|
195 |
export = view.export |
e79e7a22326f
Add an export() view, and implement it as text/text for Document.
Todd Larsen <tlarsen@google.com>
parents:
857
diff
changeset
|
196 |