author | Lennard de Rijk <ljvderijk@gmail.com> |
Sun, 25 Oct 2009 18:49:29 -0700 | |
changeset 3055 | 7f922641ccc9 |
parent 3032 | f3886d1b00a5 |
permissions | -rw-r--r-- |
980
3f3f7ec251bf
Added Club Members to SoC.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
1 |
#!/usr/bin/python2.5 |
3f3f7ec251bf
Added Club Members to SoC.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
2 |
# |
1307
091a21cf3627
Update the copyright notice for 2009.
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1248
diff
changeset
|
3 |
# Copyright 2009 the Melange authors. |
980
3f3f7ec251bf
Added Club Members to SoC.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
4 |
# |
3f3f7ec251bf
Added Club Members to SoC.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
5 |
# Licensed under the Apache License, Version 2.0 (the "License"); |
3f3f7ec251bf
Added Club Members to SoC.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
6 |
# you may not use this file except in compliance with the License. |
3f3f7ec251bf
Added Club Members to SoC.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
7 |
# You may obtain a copy of the License at |
3f3f7ec251bf
Added Club Members to SoC.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
8 |
# |
3f3f7ec251bf
Added Club Members to SoC.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
9 |
# http://www.apache.org/licenses/LICENSE-2.0 |
3f3f7ec251bf
Added Club Members to SoC.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
10 |
# |
3f3f7ec251bf
Added Club Members to SoC.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
11 |
# Unless required by applicable law or agreed to in writing, software |
3f3f7ec251bf
Added Club Members to SoC.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
12 |
# distributed under the License is distributed on an "AS IS" BASIS, |
3f3f7ec251bf
Added Club Members to SoC.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
13 |
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
3f3f7ec251bf
Added Club Members to SoC.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
14 |
# See the License for the specific language governing permissions and |
3f3f7ec251bf
Added Club Members to SoC.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
15 |
# limitations under the License. |
3f3f7ec251bf
Added Club Members to SoC.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
16 |
|
3f3f7ec251bf
Added Club Members to SoC.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
17 |
"""Views for Club Members. |
3f3f7ec251bf
Added Club Members to SoC.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
18 |
""" |
3f3f7ec251bf
Added Club Members to SoC.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
19 |
|
3f3f7ec251bf
Added Club Members to SoC.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
20 |
__authors__ = [ |
3f3f7ec251bf
Added Club Members to SoC.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
21 |
'"Lennard de Rijk" <ljvderijk@gmail.com>' |
3f3f7ec251bf
Added Club Members to SoC.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
22 |
] |
3f3f7ec251bf
Added Club Members to SoC.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
23 |
|
3f3f7ec251bf
Added Club Members to SoC.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
24 |
|
3f3f7ec251bf
Added Club Members to SoC.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
25 |
from django import forms |
3f3f7ec251bf
Added Club Members to SoC.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
26 |
|
3f3f7ec251bf
Added Club Members to SoC.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
27 |
from soc.logic import dicts |
3f3f7ec251bf
Added Club Members to SoC.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
28 |
from soc.logic.models import club as club_logic |
2019
90285a09e26e
Fixed access check in club_member view.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2018
diff
changeset
|
29 |
from soc.logic.models import club_member as club_member_logic |
1163
d8c50be19232
Cleaned up access.py
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1116
diff
changeset
|
30 |
from soc.logic.models import club_admin as club_admin_logic |
980
3f3f7ec251bf
Added Club Members to SoC.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
31 |
from soc.views.helper import access |
1583 | 32 |
from soc.views.helper import decorators |
980
3f3f7ec251bf
Added Club Members to SoC.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
33 |
from soc.views.helper import dynaform |
3f3f7ec251bf
Added Club Members to SoC.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
34 |
from soc.views.helper import widgets |
3f3f7ec251bf
Added Club Members to SoC.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
35 |
from soc.views.models import club as club_view |
3f3f7ec251bf
Added Club Members to SoC.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
36 |
from soc.views.models import role |
3f3f7ec251bf
Added Club Members to SoC.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
37 |
|
3f3f7ec251bf
Added Club Members to SoC.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
38 |
import soc.logic.models.club_member |
1067
ecf3df87b81c
Added manage view for Club Admins, Club Members and Hosts.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1030
diff
changeset
|
39 |
import soc.logic.models.club_admin |
980
3f3f7ec251bf
Added Club Members to SoC.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
40 |
|
3f3f7ec251bf
Added Club Members to SoC.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
41 |
|
3f3f7ec251bf
Added Club Members to SoC.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
42 |
class View(role.View): |
3f3f7ec251bf
Added Club Members to SoC.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
43 |
"""View methods for the Club Member model. |
3f3f7ec251bf
Added Club Members to SoC.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
44 |
""" |
3f3f7ec251bf
Added Club Members to SoC.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
45 |
|
3f3f7ec251bf
Added Club Members to SoC.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
46 |
def __init__(self, params=None): |
3f3f7ec251bf
Added Club Members to SoC.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
47 |
"""Defines the fields and methods required for the base View class |
3f3f7ec251bf
Added Club Members to SoC.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
48 |
to provide the user with list, public, create, edit and delete views. |
3f3f7ec251bf
Added Club Members to SoC.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
49 |
|
3f3f7ec251bf
Added Club Members to SoC.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
50 |
Params: |
3f3f7ec251bf
Added Club Members to SoC.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
51 |
params: a dict with params for this View |
3f3f7ec251bf
Added Club Members to SoC.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
52 |
""" |
3f3f7ec251bf
Added Club Members to SoC.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
53 |
|
1007
3b66772d21a5
Major refactor of the access module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
998
diff
changeset
|
54 |
rights = access.Checker(params) |
3b66772d21a5
Major refactor of the access module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
998
diff
changeset
|
55 |
rights['create'] = ['checkIsDeveloper'] |
2919
cb677410c0f1
Using the new checkIsMyActiveRole check where necessary.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2667
diff
changeset
|
56 |
rights['edit'] = [('checkIsMyActiveRole', club_member_logic.logic)] |
1007
3b66772d21a5
Major refactor of the access module
Sverre Rabbelier <srabbelier@gmail.com>
parents:
998
diff
changeset
|
57 |
rights['delete'] = ['checkIsDeveloper'] |
1248
f318538394d9
Rename checkHasActiveRole to checkHasActiveRoleForScope
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1203
diff
changeset
|
58 |
rights['invite'] = [('checkHasActiveRoleForScope', club_admin_logic.logic)] |
3055
7f922641ccc9
Edited the necessary access checks for all the Role views in Core and GHOP.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
3032
diff
changeset
|
59 |
rights['accept_invite'] = ['checkCanCreateFromRequest'] |
1012
73f0b61f2d9d
Fold checkAgreesToSiteToS into checkIsUser
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1007
diff
changeset
|
60 |
rights['request'] = ['checkIsUser', |
3032
f3886d1b00a5
Changed checkCanMakeRequestToGroup to use Logic instance instead of module.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2919
diff
changeset
|
61 |
('checkCanMakeRequestToGroup', club_logic.logic)] |
3055
7f922641ccc9
Edited the necessary access checks for all the Role views in Core and GHOP.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
3032
diff
changeset
|
62 |
rights['process_request'] = [('checkCanProcessRequest', |
7f922641ccc9
Edited the necessary access checks for all the Role views in Core and GHOP.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
3032
diff
changeset
|
63 |
[[club_admin_logic.logic]])] |
1163
d8c50be19232
Cleaned up access.py
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1116
diff
changeset
|
64 |
rights['manage'] = [('checkIsAllowedToManageRole', |
1184
bd9c6101d41d
Use .logic in checkIsAllowedToManageRole at the caller
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1163
diff
changeset
|
65 |
[soc.logic.models.club_member.logic, |
bd9c6101d41d
Use .logic in checkIsAllowedToManageRole at the caller
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1163
diff
changeset
|
66 |
club_admin_logic.logic])] |
980
3f3f7ec251bf
Added Club Members to SoC.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
67 |
|
3f3f7ec251bf
Added Club Members to SoC.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
68 |
new_params = {} |
3f3f7ec251bf
Added Club Members to SoC.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
69 |
new_params['logic'] = soc.logic.models.club_member.logic |
3f3f7ec251bf
Added Club Members to SoC.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
70 |
new_params['group_logic'] = club_logic.logic |
990
fd1e6afb2d62
Added two needed redirects in role.py.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
980
diff
changeset
|
71 |
new_params['group_view'] = club_view.view |
980
3f3f7ec251bf
Added Club Members to SoC.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
72 |
new_params['rights'] = rights |
3f3f7ec251bf
Added Club Members to SoC.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
73 |
|
3f3f7ec251bf
Added Club Members to SoC.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
74 |
new_params['scope_view'] = club_view |
3f3f7ec251bf
Added Club Members to SoC.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
75 |
|
3f3f7ec251bf
Added Club Members to SoC.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
76 |
new_params['name'] = "Club Member" |
1025
1f83f05f522b
Add grouping to the existing views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1012
diff
changeset
|
77 |
new_params['sidebar_grouping'] = 'Clubs' |
980
3f3f7ec251bf
Added Club Members to SoC.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
78 |
|
1076
063194eaf87b
Added agreed_to_tos_on field in user and role model.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1067
diff
changeset
|
79 |
new_params['extra_dynaexclude'] = ['agreed_to_tos'] |
980
3f3f7ec251bf
Added Club Members to SoC.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
80 |
|
3f3f7ec251bf
Added Club Members to SoC.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
81 |
new_params['allow_requests_and_invites'] = True |
1384
bb22ea156567
Role overview membership is now determined by setting show_in_roles_overview param to true in the view.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1343
diff
changeset
|
82 |
new_params['show_in_roles_overview'] = False |
980
3f3f7ec251bf
Added Club Members to SoC.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
83 |
|
3f3f7ec251bf
Added Club Members to SoC.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
84 |
params = dicts.merge(params, new_params) |
3f3f7ec251bf
Added Club Members to SoC.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
85 |
|
3f3f7ec251bf
Added Club Members to SoC.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
86 |
super(View, self).__init__(params=params) |
3f3f7ec251bf
Added Club Members to SoC.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
87 |
|
998
125257161908
Implemented the listing of all the roles in for a specific group.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
990
diff
changeset
|
88 |
# register the role with the group_view |
2667
260aaea36e49
Use role_name to register the Role with the Group View.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2177
diff
changeset
|
89 |
self._params['group_view'].registerRole(self._logic.role_name, self) |
998
125257161908
Implemented the listing of all the roles in for a specific group.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
990
diff
changeset
|
90 |
|
980
3f3f7ec251bf
Added Club Members to SoC.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
91 |
# create and store the special form for invited users |
3f3f7ec251bf
Added Club Members to SoC.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
92 |
updated_fields = { |
3f3f7ec251bf
Added Club Members to SoC.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
93 |
'link_id': forms.CharField(widget=widgets.ReadOnlyInput(), |
3f3f7ec251bf
Added Club Members to SoC.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
94 |
required=False)} |
3f3f7ec251bf
Added Club Members to SoC.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
95 |
|
3f3f7ec251bf
Added Club Members to SoC.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
96 |
invited_create_form = dynaform.extendDynaForm( |
3f3f7ec251bf
Added Club Members to SoC.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
97 |
dynaform = self._params['create_form'], |
1430
ff8cc6b15e6a
Rename dynafields to dynaproperties
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1384
diff
changeset
|
98 |
dynaproperties = updated_fields) |
980
3f3f7ec251bf
Added Club Members to SoC.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
99 |
|
2177
e2c193e1f631
Do not rely on dicts.merge to change target
Sverre Rabbelier <srabbelier@gmail.com>
parents:
2076
diff
changeset
|
100 |
self._params['invited_create_form'] = invited_create_form |
980
3f3f7ec251bf
Added Club Members to SoC.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
101 |
|
3f3f7ec251bf
Added Club Members to SoC.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
102 |
def _editPost(self, request, entity, fields): |
3f3f7ec251bf
Added Club Members to SoC.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
103 |
"""See base.View._editPost(). |
3f3f7ec251bf
Added Club Members to SoC.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
104 |
""" |
3f3f7ec251bf
Added Club Members to SoC.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
105 |
|
3f3f7ec251bf
Added Club Members to SoC.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
106 |
if not entity: |
3f3f7ec251bf
Added Club Members to SoC.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
107 |
fields['user'] = fields['link_id'] |
3f3f7ec251bf
Added Club Members to SoC.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
108 |
fields['link_id'] = fields['user'].link_id |
3f3f7ec251bf
Added Club Members to SoC.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
109 |
|
3f3f7ec251bf
Added Club Members to SoC.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
110 |
super(View, self)._editPost(request, entity, fields) |
3f3f7ec251bf
Added Club Members to SoC.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
111 |
|
3f3f7ec251bf
Added Club Members to SoC.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
112 |
|
3f3f7ec251bf
Added Club Members to SoC.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
113 |
view = View() |
3f3f7ec251bf
Added Club Members to SoC.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff
changeset
|
114 |
|
1584
d8ba8c917f37
Make use of decorators.view for all views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1583
diff
changeset
|
115 |
accept_invite = decorators.view(view.acceptInvite) |
d8ba8c917f37
Make use of decorators.view for all views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1583
diff
changeset
|
116 |
admin = decorators.view(view.admin) |
d8ba8c917f37
Make use of decorators.view for all views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1583
diff
changeset
|
117 |
create = decorators.view(view.create) |
d8ba8c917f37
Make use of decorators.view for all views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1583
diff
changeset
|
118 |
delete = decorators.view(view.delete) |
d8ba8c917f37
Make use of decorators.view for all views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1583
diff
changeset
|
119 |
edit = decorators.view(view.edit) |
d8ba8c917f37
Make use of decorators.view for all views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1583
diff
changeset
|
120 |
invite = decorators.view(view.invite) |
d8ba8c917f37
Make use of decorators.view for all views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1583
diff
changeset
|
121 |
list = decorators.view(view.list) |
d8ba8c917f37
Make use of decorators.view for all views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1583
diff
changeset
|
122 |
manage = decorators.view(view.manage) |
d8ba8c917f37
Make use of decorators.view for all views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1583
diff
changeset
|
123 |
process_request = decorators.view(view.processRequest) |
2076
1cd180cc56c9
Style fixes and removal of unused imports in soc.views.models.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
2020
diff
changeset
|
124 |
role_request = decorators.view(view.request) |
1584
d8ba8c917f37
Make use of decorators.view for all views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1583
diff
changeset
|
125 |
public = decorators.view(view.public) |
d8ba8c917f37
Make use of decorators.view for all views
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1583
diff
changeset
|
126 |
export = decorators.view(view.export) |